- Issue created by @andy-blum
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
If I install 10.1.x demo_umami and and make the following change:
diff --git a/core/profiles/demo_umami/themes/umami/templates/layout/page.html.twig b/core/profiles/demo_umami/themes/umami/templates/layout/page.html.twig index 5215326a3f2..054385ccccc 100644 --- a/core/profiles/demo_umami/themes/umami/templates/layout/page.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/layout/page.html.twig @@ -52,6 +52,7 @@ {{ page.pre_header }} {% endif %} {% if page.header|render|striptags|trim is not empty %} + {{ dump() }} {{ page.header }} {% endif %} </div>
Log in as admin and enable twig debugging in the UI (nice!) and then return to the frontend. It works as expected. The assets are attached and the var is dumped and I can expand sections and it's great. @andy-blum which template are you adding a dump to and which URL are you visiting?
- 🇺🇸United States andy-blum Ohio, USA
I'm editing the block--system-branding-block.html.twig file within the umami theme. The exact markup:
{% block content %} {{ dump() }} {% if site_logo %} <a href="{{ path('<front>') }}" rel="home" class="site-logo"> <img src="{{ site_logo }}" alt="{{ 'Home'|t }}" /> </a> {% endif %} {% if site_name %} <div class="site-name"> <a href="{{ path('<front>') }}" rel="home">{{ site_name }}</a> </div> {% endif %} {% if site_slogan %} <div class="site-slogan">{{ site_slogan }}</div> {% endif %} {% endblock %}
It seems the exact combination that's breaking this for me is:
- Twig debug mode: Enabled
- Do not cache markup: Enabled
The "Disable Twig cache" option does not seem to make a difference.
- 🇺🇸United States andy-blum Ohio, USA
If I move my {{ dump() }} to the page.html.twig file where Alex put his, the symfony debugger works.
- 🇺🇸United States andy-blum Ohio, USA
Perhaps it's related to something with blocks? block--bundle--banner-block.html.twig also prints out a broken dump
- 🇫🇮Finland olli
Looks like a problem with blocks in umami's pre_header and header regions:
umami/templates/layout/page.html.twig
renders those blocks twice ignoring the output of first|render
wheredump()
sends the necessary CSS/JS. - 🇺🇸United States andy-blum Ohio, USA
Confirming olli's comments - if I remove the uses of
|render|striptags|trim
then the dumps come through fine - 🇬🇧United Kingdom alexpott 🇪🇺🌍
Oh of course this is Umami's only render some divs if there are blocks code causing problems!
I.e stuff like:
{% if page.header|render|striptags|trim is not empty %} {{ page.header }} {% endif %}
So... there are v old issues about how to determine if something is empty. Oh Nice @andy-blum has already related 🌱 [meta] Themes improperly check renderable arrays when determining visibility Needs work ... I think we should review the following code anyway...
{% if page.pre_header| is not empty or page.header|render|striptags|trim is not empty %} <header class="layout-header" role="banner"> <div class="container"> {% if page.pre_header|render|striptags|trim is not empty %} {{ page.pre_header }} {% endif %} {% if page.header|render|striptags|trim is not empty %} {{ page.header }} {% endif %} </div> </header> {% endif %}
as the multiple
page.header|render|striptags|trim
looks really wasteful even if internal optimisations in the render system mean it's not that bad.I think this issue is a duplicate of 🐛 Umami theme ignores placeholders and HTML replaced elements when checking for empty regions Needs work