Skip to content

Commit 5bad947

Browse files
committed
bug #4023 Fix CaptureNode for some use cases (fabpot)
This PR was merged into the 3.x branch. Discussion ---------- Fix CaptureNode for some use cases Closes #4022 Commits ------- 64cebe0 Fix CaptureNode for some use cases
2 parents 2105d65 + 64cebe0 commit 5bad947

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 3.9.1 (2024-XX-XX)
22

3-
* n/a
3+
* Fix missing `$blocks` variable in `CaptureNode`
44

55
# 3.9.0 (2024-04-16)
66

src/Node/MacroNode.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public function compile(Compiler $compiler): void
7979
;
8080
}
8181

82+
$node = new CaptureNode($this->getNode('body'), $this->getNode('body')->lineno, $this->getNode('body')->tag);
83+
$node->setAttribute('with_blocks', true);
84+
8285
$compiler
8386
->write('')
8487
->string(self::VARARGS_NAME)
@@ -88,7 +91,7 @@ public function compile(Compiler $compiler): void
8891
->write("]);\n\n")
8992
->write("\$blocks = [];\n\n")
9093
->write('return ')
91-
->subcompile(new CaptureNode($this->getNode('body'), $this->getNode('body')->lineno, $this->getNode('body')->tag))
94+
->subcompile($node)
9295
->raw("\n")
9396
->outdent()
9497
->write("}\n\n")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
macro
3+
--TEMPLATE--
4+
{{ _self.some_macro() }}
5+
6+
{% macro some_macro() %}
7+
{% apply spaceless %}
8+
{% if true %}foo{% endif %}
9+
{% endapply %}
10+
{% endmacro %}
11+
--DATA--
12+
return []
13+
--EXPECT--
14+
foo

0 commit comments

Comments
 (0)