Fix nested block() resolution when a directly rendered block calls parent()

This commit is contained in:
Fabien Potencier
2026-06-03 22:09:09 +02:00
parent a0093cd699
commit 2171127676
3 changed files with 31 additions and 0 deletions
@@ -0,0 +1,28 @@
--TEST--
#3321 block() resolves nested block() calls against the overriding template even when going through parent()
--TEMPLATE--
{{ block('block1', 'theme.html.twig') }}
--TEMPLATE(theme.html.twig)--
{% extends 'base.html.twig' %}
{%- block block1 -%}
{{- parent() -}}
BLOCK1THEME/
{%- endblock -%}
{%- block block2 -%}
BLOCK2THEME/
{%- endblock -%}
--TEMPLATE(base.html.twig)--
{%- block block1 -%}
BLOCK1BASE/
{{- block('block2') -}}
{%- endblock -%}
{%- block block2 -%}
BLOCK2BASE/
{%- endblock -%}
--DATA--
return []
--EXPECT--
BLOCK1BASE/BLOCK2THEME/BLOCK1THEME/