The menu.html.twig
file contain 2 <ul>
tags and therefor the indention of the twig file is a bit uncommon. Also, text editors like PHPStorm have difficulties figuring out what the DOM looks like because they can't find a closing tag for the second <ul>
.
This issue can be fixed by moving the if test inside the <ul>
.
Before:
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
{% if items %}
{% if menu_level == 0 %}
<ul{{ attributes }}>
{% else %}
<ul>
{% endif %}
{% for item in items %}
<li{{ item.attributes }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
After:
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
{% if items %}
<ul{{ menu_level == 0 ? attributes }}>
{% for item in items %}
<li{{ item.attributes }}>
{{ link(item.title, item.url) }}
{% if item.below %}
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
This patch also includes a fix for the stable, classy & unami themes.