gantry5
gantry5 copied to clipboard
Whitespace characters added before <!DOCTYPE html> in gravcms with helium template
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: 3f70ca038cab99cae266d1f1158d097358653636
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>