Commit 56bd88c9 by Seldaek

* The Compiler now ensures that a template starting with <?xml will not conflict…

* The Compiler now ensures that a template starting with <?xml will not conflict with php using the short_open_tag=On setting git-svn-id: svn://dwoo.org/dwoo/trunk@159 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent 2eb52110
......@@ -2,6 +2,8 @@
+ API: Added Dwoo_Compilation_Exception methods getCompiler() and
getTemplate() so you can catch the exception and use those to build a nicer
error view with all the details you want
* The Compiler now ensures that a template starting with <?xml will not
conflict with php using the short_open_tag=On setting
* Fixed compiler bug that created a parse error when you had comments in an
extended template
* Fixed extends bug when extending files in other directories using relative
......
......@@ -746,6 +746,9 @@ class Dwoo_Compiler implements Dwoo_ICompiler
$output = preg_replace('/(?<!;|\}|\*\/|\n|\{)(\s*'.preg_quote(self::PHP_CLOSE, '/') . preg_quote(self::PHP_OPEN, '/').')/', ";\n", $output);
$output = str_replace(self::PHP_CLOSE . self::PHP_OPEN, "\n", $output);
// handle <?xml tag at the beginning
$output = preg_replace('#(/\* template body \*/ \?>\s*)<\?xml#is', '$1<?php echo \'<?xml\'; ?>', $output);
if ($this->debug) {
echo '<hr><pre>';
$lines = preg_split('{\r\n|\n|<br />}', highlight_string(($output), true));
......
......@@ -27,11 +27,11 @@ final class Dwoo_Plugin_topLevelBlock extends Dwoo_Block_Plugin implements Dwoo_
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
{
return 'ob_start(); '.Dwoo_Compiler::PHP_CLOSE;
return 'ob_start(); /* template body */ '.Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
{
return $content . Dwoo_Compiler::PHP_OPEN.'return $this->buffer . ob_get_clean();';
return $content . Dwoo_Compiler::PHP_OPEN.' /* end template body */'."\n".'return $this->buffer . ob_get_clean();';
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment