From: Fabien Potencier Date: Sat, 21 Jul 2012 20:47:06 +0000 (+0200) Subject: moved some macro related logic to the generated code X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b5d62a192e53a3b6622f3e9bc2a57bbf6bc91d3a;p=web%2Fkonrad%2Ftwig.git moved some macro related logic to the generated code --- diff --git a/lib/Twig/Node/Macro.php b/lib/Twig/Node/Macro.php index e0c3dca..823131e 100644 --- a/lib/Twig/Node/Macro.php +++ b/lib/Twig/Node/Macro.php @@ -76,7 +76,7 @@ class Twig_Node_Macro extends Twig_Node ->write("throw \$e;\n") ->outdent() ->write("}\n\n") - ->write("return ob_get_clean();\n") + ->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n") ->outdent() ->write("}\n\n") ; diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 7b98468..beed5c5 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -422,14 +422,7 @@ abstract class Twig_Template implements Twig_TemplateInterface $this->env->getExtension('sandbox')->checkMethodAllowed($object, $method); } - $ret = call_user_func_array(array($object, $method), $arguments); - - // hack to be removed when macro calls are refactored - if ($object instanceof Twig_TemplateInterface) { - return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset()); - } - - return $ret; + return call_user_func_array(array($object, $method), $arguments); } /** diff --git a/test/Twig/Tests/Node/MacroTest.php b/test/Twig/Tests/Node/MacroTest.php index 3dd57a6..5930728 100644 --- a/test/Twig/Tests/Node/MacroTest.php +++ b/test/Twig/Tests/Node/MacroTest.php @@ -61,7 +61,7 @@ public function getfoo(\$foo = null) throw \$e; } - return ob_get_clean(); + return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset()); } EOF ),