Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:gantry/gantry5 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Jan 2, 2020
2 parents cbcd51a + 51da034 commit 0836d32
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions engines/common/nucleus/particles/menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -42,44 +42,41 @@
{% set dropdown = item.level == 1 ? ' g-' ~ item.getDropdown() %}
{% set parent = item.children ? ' g-parent' %}
{% set target = (item.target != '_self' or context.particle.forceTarget) ? ' target="' ~ item.target|e ~ '"' %}
{% set rel = item.rel %}

{% if item.target == '_blank' %}
{% set relTarget = ('noopener' not in item.rel) ? 'noopener' : '' %}
{% if 'noreferrer' not in item.rel %}
{% set relTarget = (relTarget) ? relTarget ~ ' ' : relTarget %}
{% set relTarget = relTarget ~ 'noreferrer' %}
{% if 'noopener' not in rel %}
{% set rel = rel ? rel ~ ' ' : rel %}
{% set rel = rel ~ 'noopener' %}
{% endif %}
{% if 'noreferrer' not in rel %}
{% set rel = rel ? rel ~ ' ' : rel %}
{% set rel = rel ~ 'noreferrer' %}
{% endif %}
{% set relTarget = (item.rel and relTarget) ? ' ' ~ relTarget : relTarget %}
{% endif %}

{% set listAttributes = '' %}
{% if item.attributes %}
{% for attribute in item.attributes %}
{% for key, value in attribute %}
{% set listAttributes = listAttributes ~ ' ' ~ key|e ~ '="' ~ value|e('html_attr') ~ '"' %}
{% endfor %}
{% endfor %}
{% endif %}

{% set listAttributes = item.attributes|attribute_array %}
{% set linkAttributes = '' %}
{% set relAttribute = '' %}

{% if item.link_attributes %}
{% for attribute in item.link_attributes %}
{% for key, value in attribute %}
{% if key == 'rel' %}
{% set hValue = value|e('html_attr') %}
{% if hValue not in item.rel and hValue not in relTarget %}
{% set relAttribute = (item.rel or relTarget) ? ' ' : '' %}
{% set relAttribute = relAttribute ~ hValue %}
{% endif %}
{% for hVal in value|split(' ') %}
{% if hVal not in rel %}
{% set rel = rel ? rel ~ ' ' : rel %}
{% set rel = rel ~ hVal %}
{% endif %}
{% endfor %}
{% else %}
{% set linkAttributes = linkAttributes ~ ' ' ~ key|e ~ '="' ~ value|e('html_attr') ~ '"' %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
{% set rel = (item.rel or relTarget or relAttribute) ? ' rel="' ~ item.rel|e ~ relTarget ~ relAttribute ~ '"' %}

{% set rel = rel ? ' rel="' ~ rel|e('html_attr') ~ '"' %}

<li class="g-menu-item g-menu-item-type-{{ item.type }} g-menu-item-{{ item.id }}{% if not item.dropdown_hide %}{{ parent }}{% endif %}{{ active }}{{ dropdown }} {% if item.url and item.children %}{% if not item.dropdown_hide %}g-menu-item-link-parent{% endif %}{% endif %} {{ item.class|default('') }}"
{{- self.getCustomWidth(item, menu, 'item', dropdown) }}
{%- if context.particle.renderTitles|default(0) %} title="{{ item.title }}"{% endif %}{{listAttributes|raw}}>
Expand Down

0 comments on commit 0836d32

Please sign in to comment.