Merge branch '3.x' into 4.x

* 3.x:
  Add twig_escape_filter_is_safe() as deprecated.
  Bump version
  Prepare the 3.9.2 release
  Fix usage of display_end hook
  Require correct twig core version
  Bump version
  Prepare the 3.9.1 release
  Fix CaptureNode for some use cases
  Bump version
  Prepare the 3.9.0 release
  Update CHANGELOG
This commit is contained in:
Fabien Potencier
2024-04-17 15:30:31 -04:00
4 changed files with 24 additions and 4 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
],
"require": {
"php": ">=8.2",
"twig/twig": "^3.0",
"twig/twig": "^3.9",
"symfony/intl": "^5.4|^6.4|^7.0"
},
"require-dev": {
+4 -1
View File
@@ -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")
+5 -2
View File
@@ -336,12 +336,15 @@ final class ModuleNode extends Node
$compiler->raw('$this->getParent($context)');
}
$compiler->raw("->unwrap()->yield(\$context, array_merge(\$this->blocks, \$blocks));\n");
} else {
}
$compiler->subcompile($this->getNode('display_end'));
if (!$this->hasNode('parent')) {
$compiler->write("return; yield '';\n"); // ensure at least one yield call even for templates with no output
}
$compiler
->subcompile($this->getNode('display_end'))
->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