{% extends 'knp_menu.html.twig' %} {% macro local_attributes(attributes) %} {% for name, value in attributes %} {%- if value is not none and value is not same as(false) -%} {{- ' %s="%s"'|format(name, value is same as(true) ? name|e : value|e)|raw -}} {%- endif -%} {%- endfor -%} {% endmacro %} {% block compressed_root %} {% apply spaceless %} {{ block('root') }} {% endapply %} {% endblock %} {% block root %} {% set listAttributes = item.childrenAttributes %} {{ block('list') -}} {% endblock %} {% block list %} {% if item.hasChildren and options.depth is not same as(0) and item.displayChildren %} {% import _self as macros %} {{ block('children') }} {% endif %} {% endblock %} {% block children %} {# save current variables #} {% set currentOptions = options %} {% set currentItem = item %} {# update the depth for children #} {% if options.depth is not none %} {% set options = options|merge({'depth': currentOptions.depth - 1}) %} {% endif %} {# update the matchingDepth for children #} {% if options.matchingDepth is not none and options.matchingDepth > 0 %} {% set options = options|merge({'matchingDepth': currentOptions.matchingDepth - 1}) %} {% endif %} {% for item in currentItem.children %} {{ block('item') }} {% endfor %} {# restore current variables #} {% set item = currentItem %} {% set options = currentOptions %} {% endblock %} {% block item %} {#{% import "knp_menu.html.twig" as macros %}#} {% import _self as macros %} {% if item.displayed %} {%- set attributes = item.attributes %} {# building the class of the item #} {%- set classes = item.attribute('class') is not empty ? [item.attribute('class')] : [] %} {%- if matcher.isCurrent(item) %} {%- set classes = classes|merge([options.currentClass]) %} {%- elseif matcher.isAncestor(item, options.depth) %} {%- set classes = classes|merge([options.ancestorClass]) %} {%- endif %} {# building the class of the children #} {%- set childrenClasses = item.childrenAttribute('class') is not empty ? [item.childrenAttribute('class')] : [] %} {# putting classes together #} {%- if classes is not empty %} {%- set attributes = attributes|merge({'class': classes|join(' ')}) %} {%- endif %} {%- set listAttributes = item.childrenAttributes|merge({'class': childrenClasses|join(' ') }) %} {# displaying the item #} {%- if item.uri is not empty and (not item.current or options.currentAsLink) %} {{ block('linkElement') }} {%- else %} {{ block('spanElement') }} {%- endif %} {# render the list of children#} {{ block('list') }} {% endif %} {% endblock %} {% block linkElement %} {% import _self as macros %} {% if item.getExtra('mi') is not empty %} {{ item.getExtra('mi') }} {% elseif item.getExtra('fa') is not empty%} {% endif %} {{ block('label') }} {% if item.getExtra('icon') is not empty %} {% endif %} {% endblock %} {% block spanElement %} {% import _self as macros %} {{ macros.local_attributes(item.labelAttributes) }}> {% if item.getExtra('mi') is not empty %} {{ item.getExtra('mi') }} {% elseif item.getExtra('fa') is not empty%} {% endif %} {{ block('label') }} {% if item.getExtra('icon') is not empty %} {% endif %} {% endblock %} {% block label %} {% if options.allow_safe_labels and item.getExtra('safe_label', false) %} {{ item.label|raw }} {% else %} {{ item.label }} {% endif %} {% endblock %}