Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitespace characters added before <!DOCTYPE html> in gravcms with helium template #3287

Open
vangogs opened this issue Nov 27, 2024 · 0 comments

Comments

@vangogs
Copy link

vangogs commented Nov 27, 2024

How to repeat
Download/Install clean latest (v1.7.48) grav-admin package, Install Gantry5 (v5.5.19) and Helium, activate Helium template
(repeated on php 8.2.20 and 7.4).
Open homepage source
There will be multiple white-space characters before <!DOCTYPE html> tag.

Problem root-cause
Problem introduced by commit: 3f70ca0

Original code in engines/common/nucleus/templates/page.html.twig:

{%- for segment in segments if segment.type == 'offcanvas' %}
    {%- set offcanvas = segment -%}
{% endfor -%}

Replaced by:

{%- for segment in segments %}
    {% if segment.type == 'offcanvas' %}
        {%- set offcanvas = segment -%}
    {% endif %}
{% endfor -%}

And

    {% for segment in segments if segment.type != 'offcanvas' %}
        {% include '@nucleus/layout/' ~ segment.type ~ '.html.twig' with { 'segments': segment.children } %}
    {% endfor %}

Replaced by:

    {% for segment in segments %}
        {% if segment.type != 'offcanvas' %}
            {% include '@nucleus/layout/' ~ segment.type ~ '.html.twig' with { 'segments': segment.children } %}
        {% endif %}
    {% endfor %}

It is somehow related to particles, because white-spaces are added as per particles in the layout.

How to fix
Roll back these two changes and HTML will be rendered correctly without blanks before <!DOCTYPE html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant