mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 12:26:30 +00:00
Fix CaptureNode for some use cases
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# 3.9.1 (2024-XX-XX)
|
# 3.9.1 (2024-XX-XX)
|
||||||
|
|
||||||
* n/a
|
* Fix missing `$blocks` variable in `CaptureNode`
|
||||||
|
|
||||||
# 3.9.0 (2024-04-16)
|
# 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
|
$compiler
|
||||||
->write('')
|
->write('')
|
||||||
->string(self::VARARGS_NAME)
|
->string(self::VARARGS_NAME)
|
||||||
@@ -88,7 +91,7 @@ class MacroNode extends Node
|
|||||||
->write("]);\n\n")
|
->write("]);\n\n")
|
||||||
->write("\$blocks = [];\n\n")
|
->write("\$blocks = [];\n\n")
|
||||||
->write('return ')
|
->write('return ')
|
||||||
->subcompile(new CaptureNode($this->getNode('body'), $this->getNode('body')->lineno, $this->getNode('body')->tag))
|
->subcompile($node)
|
||||||
->raw("\n")
|
->raw("\n")
|
||||||
->outdent()
|
->outdent()
|
||||||
->write("}\n\n")
|
->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