{% extends 'knp_menu_base.html.twig' %} {% macro attributes(attributes) %} {% for name, value in attributes %} {%- if value is not none and value is not sameas(false) -%} {{- ' %s="%s"'|format(name, value is sameas(true) ? name|e : value|e)|raw -}} {%- endif -%} {%- endfor -%} {% endmacro %} {% block compressed_root %} {% spaceless %} {{ block('root') }} {% endspaceless %} {% endblock %} {% block root %} {# Twitter Bootstrap uses the CSS class "active" to indicate the current item, so lets change that. #} {% set options = options|merge({'currentDepth': 0}) %} {% if options.style is defined and options.currentClass is defined and options.currentClass == 'current' %} {% set options = options|merge({'currentClass': 'active'}) %} {% set options = options|merge({'ancestorClass': 'active'}) %} {% endif %} {% set listAttributes = item.childrenAttributes %} {{ block('list') -}} {% endblock %} {% block list %} {% if item.hasChildren and options.depth is not sameas(0) and item.displayChildren %} {% set listAttributes = listAttributes|merge({'class': listAttributes.class|default('')|trim}) %} {% set listClass = '' %} {% if options.style is defined and options.style == 'tabs' %} {% set listClass = 'nav-tabs' %} {% elseif options.style is defined and options.style == 'stacked-tabs' %} {% set listClass = 'nav-tabs nav-stacked' %} {% elseif options.style is defined and options.style == 'justified-tabs' %} {% set listClass = 'nav-tabs nav-justified' %} {% elseif options.style is defined and options.style == 'pills' %} {% set listClass = 'nav-pills' %} {% elseif options.style is defined and options.style == 'justified-pills' %} {% set listClass = 'nav-pills nav-justified' %} {% elseif options.style is defined and options.style == 'stacked-pills' %} {% set listClass = 'nav-pills nav-stacked' %} {% elseif options.style is defined and options.style == 'list' %} {% set listClass = 'nav-list' %} {% elseif options.style is defined and options.style == 'navbar' %} {% set listClass = 'navbar-nav' %} {% elseif options.style is defined and options.style == 'navbar-right' %} {% set listClass = 'navbar-nav navbar-right' %} {% endif %} {% if options.pull is defined and options.pull == 'right' %} {% set listClass = (listClass|default('') ~ ' pull-right')|trim %} {% elseif options.pull is defined and options.pull == 'left' %} {% set listClass = (listClass|default('') ~ 'pull-left')|trim %} {% endif %} {% set listClass = (options.currentDepth == 0) ? listClass ~ ' nav' : listClass %} {% set listAttributes = listAttributes|merge({'class': (listAttributes.class|default('') ~ ' ' ~ listClass)|trim}) %}