mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 02:16:41 +00:00
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
-------
64cebe0e Fix CaptureNode for some use cases
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 3.9.1 (2024-XX-XX)
|
||||
|
||||
* n/a
|
||||
* Fix missing `$blocks` variable in `CaptureNode`
|
||||
|
||||
# 3.9.0 (2024-04-16)
|
||||
|
||||
|
||||
@@ -79,6 +79,9 @@ class MacroNode extends Node
|
||||
;
|
||||
}
|
||||
|
||||
$node = new CaptureNode($this->getNode('body'), $this->getNode('body')->lineno, $this->getNode('body')->tag);
|
||||
$node->setAttribute('with_blocks', true);
|
||||
|
||||
$compiler
|
||||
->write('')
|
||||
->string(self::VARARGS_NAME)
|
||||
@@ -88,7 +91,7 @@ class MacroNode extends Node
|
||||
->write("]);\n\n")
|
||||
->write("\$blocks = [];\n\n")
|
||||
->write('return ')
|
||||
->subcompile(new CaptureNode($this->getNode('body'), $this->getNode('body')->lineno, $this->getNode('body')->tag))
|
||||
->subcompile($node)
|
||||
->raw("\n")
|
||||
->outdent()
|
||||
->write("}\n\n")
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
macro
|
||||
--TEMPLATE--
|
||||
{{ _self.some_macro() }}
|
||||
|
||||
{% macro some_macro() %}
|
||||
{% apply spaceless %}
|
||||
{% if true %}foo{% endif %}
|
||||
{% endapply %}
|
||||
{% endmacro %}
|
||||
--DATA--
|
||||
return []
|
||||
--EXPECT--
|
||||
foo
|
||||
Reference in New Issue
Block a user