{% apply spaceless %} {# Parameters: - "item" (object) - "is_current" (boolean) Whether the item is currently selected - "label" (string) Label of the menu link - "icon_path" (string) Path to the icon sprite - "trigger_aria_label" (string) Aria label for the trigger button, - "children" (array of object) Array of sub-items - "external": (boolean) External link - "is_current" (boolean) Whether the sub-item is currently selected - "path" (string) Href of the sub-item link - "label" (string) Label of the sub-item link #} {% set _item = item|default({}) %} {% set _menu_item_class = 'ecl-menu__link' %} {% set _menu_item_attributes = 'data-ecl-menu-link' %} {% set _menu_list_item_attributes = 'data-ecl-menu-item' %} {% set _menu_list_item_class = 'ecl-menu__item' %} {% set _icon_path = icon_path|default('') %} {% set _external = external|default(false) %} {% if _item.is_current is defined %} {% set _menu_item_class = _menu_item_class ~ ' ecl-menu__link--current' %} {% set _menu_list_item_class = _menu_list_item_class ~ ' ecl-menu__item--current' %} {% endif %} {% if item.children is defined and item.children is not empty and item.children is iterable %} {% set _menu_list_item_attributes = _menu_list_item_attributes ~ ' data-ecl-has-children aria-haspopup aria-expanded="false"' %} {% set _menu_list_item_class = _menu_list_item_class ~ ' ecl-menu__item--has-children' %} {% endif %}
  • {{- item.label -}} {%- if item.external -%} {% include '@ecl/icon/icon.html.twig' with { icon: { path: icon_path, name: 'external', size: 'xs', transform: 'rotate-90', }, extra_classes: 'ecl-menu__link-icon--external ecl-menu__link-icon', } %} {%- endif -%} {%- if item.children is defined and item.children is not empty and item.children is iterable -%} {% set _button_extra_attributes = [{name: 'data-ecl-menu-caret' }] %} {% if item.trigger_aria_label is not empty %} {% set _button_extra_attributes = _button_extra_attributes|merge([{ name: 'aria-label', value: item.trigger_aria_label }]) %} {% endif %} {% include '@ecl/button/button.html.twig' with { variant: 'primary', type: 'button', disabled: false, icon: { name: 'corner-arrow', size: 'xs', path: icon_path, transform: 'rotate-180', }, icon_position: 'after', extra_classes: 'ecl-menu__button-caret', extra_attributes: _button_extra_attributes, } %}
    {% endif %}
  • {% endapply %}