Skip to content

Commit

Permalink
Fix "Undefined variable $macros" when using filter in a deferred block (
Browse files Browse the repository at this point in the history
#14)

See #13.
  • Loading branch information
rybakit authored Jul 14, 2022
1 parent 9076633 commit 3f8a67f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/DeferredBlockNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function compile(Compiler $compiler) : void
->addDebugInfo($this)
->write("public function block_{$name}_deferred(\$context, array \$blocks = [])\n", "{\n")
->indent()
->write("\$macros = \$this->macros;\n")
->subcompile($this->getNode('body'))
->write("\$this->deferred->resolve(\$this, \$context, \$blocks);\n")
->outdent()
Expand Down
10 changes: 10 additions & 0 deletions tests/Fixtures/filter.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
filter
--TEMPLATE--
{% block foo deferred %}
1{% for test in test_array|default([])|filter(test => true) %}{% endfor %}2
{% endblock %}
--DATA--
return []
--EXPECT--
12

0 comments on commit 3f8a67f

Please sign in to comment.