{% extends 'knp_menu.html.twig' %} {% block item %} {% import 'knp_menu.html.twig' as macroattr %} {% if item.displayed %} {# 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.matchingDepth) %} {%- set classes = classes|merge([options.ancestorClass]) %} {%- endif %} {%- if item.actsLikeFirst %} {%- set classes = classes|merge([options.firstClass]) %} {%- endif %} {%- if item.actsLikeLast %} {%- set classes = classes|merge([options.lastClass]) %} {%- endif %} {# Mark item as "leaf" (no children) or as "branch" (has children that are displayed) #} {% if item.hasChildren and options.depth is not same as(0) %} {%- set classes = classes|merge(['dropdown']) %} {% if options.branch_class is not empty and item.displayChildren %} {%- set classes = classes|merge([options.branch_class]) %} {% endif %} {% elseif options.leaf_class is not empty %} {%- set classes = classes|merge([options.leaf_class]) %} {%- endif %} {%- set attributes = item.attributes %} {%- if classes is not empty %} {%- set attributes = attributes|merge({'class': classes|join(' ')}) %} {%- endif %} {# displaying the item #}