fixed output when a macro throws an exception

This commit is contained in:
Fabien Potencier
2011-07-25 18:12:16 +02:00
parent 42e4105595
commit ea83972869
3 changed files with 17 additions and 2 deletions
+1
View File
@@ -2,6 +2,7 @@
Changes:
* fixed output when a macro throws an exception
* fixed a parsing problem when a large chunk of text is enclosed in a comment tag
* 1.1.1 (2011-07-17)
+9 -1
View File
@@ -55,8 +55,16 @@ class Twig_Node_Macro extends Twig_Node
->outdent()
->write("));\n\n")
->write("ob_start();\n")
->write("try {\n")
->indent()
->subcompile($this->getNode('body'))
->raw("\n")
->outdent()
->write("} catch(Exception \$e) {\n")
->indent()
->write("ob_end_clean();\n\n")
->write("throw \$e;\n")
->outdent()
->write("}\n\n")
->write("return ob_get_clean();\n")
->outdent()
->write("}\n\n")
+7 -1
View File
@@ -51,7 +51,13 @@ public function getfoo(\$foo = null)
));
ob_start();
echo "foo";
try {
echo "foo";
} catch(Exception \$e) {
ob_end_clean();
throw \$e;
}
return ob_get_clean();
}