false]); # Read the existing syntax file with block markers in it. # $template = file_get_contents($argv[1]); # Clean up any previously defined blocks. $template = preg_replace( sprintf( '/(@block\([\'"](%s)[\'"]\)["\r\n\t ]*).*?(["\r\n\t ]*@endblock)\b/ism', implode(/* $glue = */ '|', array_keys($blocks)) ), "\\1___\\2___\\3", $template ); # Update block contents in the template. foreach ($blocks as $blockName => $lines) { $template = str_ireplace( sprintf('___%s___', $blockName), rtrim(is_array($lines) ? implode(/* $glue = */ "\n", $lines) : $lines), $template ); } $template = preg_replace_callback( '/ (?"\s*@copy\s+(?[a-zA-Z0-9_]+)(?(\s+(strip_maximum_size))+)?) (?