Commit 07e1dd9a by Jordi Boggiano

Fixed #75: Nested dynamic tags are generating parse errors in compiled templates

parent 71c1d67c
......@@ -25,6 +25,8 @@
Dwoo_Security_Policy (see allowMethod()), this is hardly efficient
though for instance calls since it has to do runtime checks so use
it with caution
* Fixed PHP parse errors being generated in compiled templates when
{dynamic} was nested
* Added $this->viewParam support to ZendFramework adapter through a
Dwoo_Adapters_ZendFramework_Dwoo class that extends Dwoo, you should use
this if you called setEngine() on the ZF view
......
......@@ -27,25 +27,30 @@ class Dwoo_Plugin_dynamic extends Dwoo_Block_Plugin implements Dwoo_ICompilable_
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
{
$output = Dwoo_Compiler::PHP_OPEN .
'if($doCache) {'."\n\t".
'echo \'<dwoo:dynamic_\'.$dynamicId.\'>'.
str_replace('\'', '\\\'', $content) .
'</dwoo:dynamic_\'.$dynamicId.\'>\';'.
"\n} else {\n\t";
if(substr($content, 0, strlen(Dwoo_Compiler::PHP_OPEN)) == Dwoo_Compiler::PHP_OPEN) {
$output .= substr($content, strlen(Dwoo_Compiler::PHP_OPEN));
} else {
$output .= Dwoo_Compiler::PHP_CLOSE . $content;
}
if(substr($output, -strlen(Dwoo_Compiler::PHP_CLOSE)) == Dwoo_Compiler::PHP_CLOSE) {
$output = substr($output, 0, -strlen(Dwoo_Compiler::PHP_CLOSE));
} else {
$output .= Dwoo_Compiler::PHP_OPEN;
}
$output .= "\n}". Dwoo_Compiler::PHP_CLOSE;
try {
$compiler->findBlock('dynamic');
$output = Dwoo_Compiler::PHP_OPEN .
'if($doCache) {'."\n\t".
'echo \'<dwoo:dynamic_\'.$dynamicId.\'>'.
str_replace('\'', '\\\'', $content) .
'</dwoo:dynamic_\'.$dynamicId.\'>\';'.
"\n} else {\n\t";
if(substr($content, 0, strlen(Dwoo_Compiler::PHP_OPEN)) == Dwoo_Compiler::PHP_OPEN) {
$output .= substr($content, strlen(Dwoo_Compiler::PHP_OPEN));
} else {
$output .= Dwoo_Compiler::PHP_CLOSE . $content;
}
if(substr($output, -strlen(Dwoo_Compiler::PHP_CLOSE)) == Dwoo_Compiler::PHP_CLOSE) {
$output = substr($output, 0, -strlen(Dwoo_Compiler::PHP_CLOSE));
} else {
$output .= Dwoo_Compiler::PHP_OPEN;
}
$output .= "\n}". Dwoo_Compiler::PHP_CLOSE;
return $output;
return $output;
} catch (Dwoo_Compilation_Exception $e) {
return $content;
}
}
public static function unescape($output, $dynamicId, $compiledFile)
......
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