fixed macros containing filter tag calls
authorFabien Potencier <fabien.potencier@gmail.com>
Sat, 3 Dec 2011 07:16:26 +0000 (08:16 +0100)
committerFabien Potencier <fabien.potencier@gmail.com>
Sat, 3 Dec 2011 07:16:26 +0000 (08:16 +0100)
CHANGELOG
lib/Twig/Node/Macro.php
test/Twig/Tests/Fixtures/macros/with_filters.test [new file with mode: 0644]
test/Twig/Tests/Node/MacroTest.php

index 14ce2c2..40d6281 100644 (file)
--- 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()
index be74726..5db1bf1 100644 (file)
@@ -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 (file)
index 0000000..685626f
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+macro with a filter
+--TEMPLATE--
+{% import _self as test %}
+
+{% macro test() %}
+    {% filter escape %}foo<br />{% endfilter %}
+{% endmacro %}
+
+{{ test.test() }}
+--DATA--
+return array();
+--EXPECT--
+foo&lt;br /&gt;
index 66d5fec..ddb67d1 100644 (file)
@@ -50,6 +50,8 @@ public function getfoo(\$foo = null)
         "foo" => \$foo,
     ));
 
+    \$blocks = array();
+
     ob_start();
     try {
         echo "foo";