From c6917a28ef7fdd23aef161a814491342db1d1199 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 3 Dec 2011 08:16:26 +0100 Subject: [PATCH] fixed macros containing filter tag calls --- CHANGELOG | 4 ++++ lib/Twig/Node/Macro.php | 1 + test/Twig/Tests/Fixtures/macros/with_filters.test | 14 ++++++++++++++ test/Twig/Tests/Node/MacroTest.php | 2 ++ 4 files changed, 21 insertions(+), 0 deletions(-) create mode 100644 test/Twig/Tests/Fixtures/macros/with_filters.test diff --git a/CHANGELOG b/CHANGELOG index 14ce2c2..40d6281 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +* 1.4.0 + + * fixed macros containing filter tag calls + * 1.4.0-RC2 (2011-11-27) * removed usage of Reflection in Twig_Template::getAttribute() diff --git a/lib/Twig/Node/Macro.php b/lib/Twig/Node/Macro.php index be74726..5db1bf1 100644 --- a/lib/Twig/Node/Macro.php +++ b/lib/Twig/Node/Macro.php @@ -64,6 +64,7 @@ class Twig_Node_Macro extends Twig_Node } $compiler + ->write("\$blocks = array();\n\n") ->write("ob_start();\n") ->write("try {\n") ->indent() diff --git a/test/Twig/Tests/Fixtures/macros/with_filters.test b/test/Twig/Tests/Fixtures/macros/with_filters.test new file mode 100644 index 0000000..685626f --- /dev/null +++ b/test/Twig/Tests/Fixtures/macros/with_filters.test @@ -0,0 +1,14 @@ +--TEST-- +macro with a filter +--TEMPLATE-- +{% import _self as test %} + +{% macro test() %} + {% filter escape %}foo
{% endfilter %} +{% endmacro %} + +{{ test.test() }} +--DATA-- +return array(); +--EXPECT-- +foo<br /> diff --git a/test/Twig/Tests/Node/MacroTest.php b/test/Twig/Tests/Node/MacroTest.php index 66d5fec..ddb67d1 100644 --- a/test/Twig/Tests/Node/MacroTest.php +++ b/test/Twig/Tests/Node/MacroTest.php @@ -50,6 +50,8 @@ public function getfoo(\$foo = null) "foo" => \$foo, )); + \$blocks = array(); + ob_start(); try { echo "foo"; -- 1.7.2.5