{# /** * @file * Default implementation for the navigation menu component. */ #} {# Process items as expected by ECL component. #} {% set _items = [] %} {% for item in items %} {# Process children, if any. #} {% set _children = [] %} {% for child in item.children %} {% set _child = { path: child.href, label: child.label, } %} {% if child.is_current is defined and child.is_current == true%} {% set _child = _child|merge({ is_current: child.is_current, }) %} {% endif %} {% if child.external is defined and child.external == true %} {% set _child = _child|merge({ external: child.external, icon_path: ecl_icon_path }) %} {% endif %} {% set _children = _children|merge([_child]) %} {% endfor %} {# Process menu items. #} {% set _item = { path: item.href, label: item.label, children: _children, trigger_aria_label: "Access item's children"|t, } %} {% if _children is empty and item.external is defined and item.external == true %} {% set _item = _item|merge({ external: item.external, icon_path: ecl_icon_path }) %} {% endif %} {% if item.is_current is defined and item.is_current == true %} {% set _item = _item|merge({ is_current: item.is_current, }) %} {% endif %} {% set _items = _items|merge([_item]) %} {% endfor %} {% if _items %} {# Add extra attributes. #} {% set extra_attributes = [ { 'name': 'aria-label', 'value': "Site navigation"|t, } ] %} {% include 'themes/custom/ewrc_theme/components/twig-component-menu/ecl-menu.html.twig' with { title: label|default('Menu'|t), close: 'Close'|t, back: 'Back'|t, site_name: site_name, items: _items, icon_path: ecl_icon_path, extra_attributes: extra_attributes|default([]), is_admin: is_admin } only %} {% endif %}