mirror of
https://github.com/twigphp/Twig.git
synced 2026-10-01 01:18:12 +00:00
use try-finally for macro compilation
This commit is contained in:
@@ -108,14 +108,14 @@ class Twig_Node_Macro extends Twig_Node
|
||||
->write("try {\n")
|
||||
->indent()
|
||||
->subcompile($this->getNode('body'))
|
||||
->raw("\n")
|
||||
->write("return ('' === \$tmp = ob_get_contents()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n")
|
||||
->outdent()
|
||||
->write("} catch (Exception \$e) {\n")
|
||||
->write("} finally {\n")
|
||||
->indent()
|
||||
->write("ob_end_clean();\n\n")
|
||||
->write("throw \$e;\n")
|
||||
->write("ob_end_clean();\n")
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n")
|
||||
->write("}\n")
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
;
|
||||
|
||||
@@ -55,13 +55,11 @@ public function macro_foo(\$__foo__ = null, \$__bar__ = "Foo"$declaration)
|
||||
ob_start();
|
||||
try {
|
||||
echo "foo";
|
||||
} catch (Exception \$e) {
|
||||
|
||||
return ('' === \$tmp = ob_get_contents()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());
|
||||
} finally {
|
||||
ob_end_clean();
|
||||
|
||||
throw \$e;
|
||||
}
|
||||
|
||||
return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());
|
||||
}
|
||||
EOF
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user