mirror of
https://github.com/twigphp/Twig.git
synced 2026-10-03 18:37:49 +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")
|
->write("try {\n")
|
||||||
->indent()
|
->indent()
|
||||||
->subcompile($this->getNode('body'))
|
->subcompile($this->getNode('body'))
|
||||||
|
->raw("\n")
|
||||||
|
->write("return ('' === \$tmp = ob_get_contents()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n")
|
||||||
->outdent()
|
->outdent()
|
||||||
->write("} catch (Exception \$e) {\n")
|
->write("} finally {\n")
|
||||||
->indent()
|
->indent()
|
||||||
->write("ob_end_clean();\n\n")
|
->write("ob_end_clean();\n")
|
||||||
->write("throw \$e;\n")
|
|
||||||
->outdent()
|
->outdent()
|
||||||
->write("}\n\n")
|
->write("}\n")
|
||||||
->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n")
|
|
||||||
->outdent()
|
->outdent()
|
||||||
->write("}\n\n")
|
->write("}\n\n")
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -55,13 +55,11 @@ public function macro_foo(\$__foo__ = null, \$__bar__ = "Foo"$declaration)
|
|||||||
ob_start();
|
ob_start();
|
||||||
try {
|
try {
|
||||||
echo "foo";
|
echo "foo";
|
||||||
} catch (Exception \$e) {
|
|
||||||
|
return ('' === \$tmp = ob_get_contents()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());
|
||||||
|
} finally {
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
throw \$e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());
|
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user