|
| 1 | +{# |
| 2 | +/** |
| 3 | + * @file |
| 4 | + * from bootstrap theme |
| 5 | + */ |
| 6 | +#} |
| 7 | + |
| 8 | +{% import _self as menus %} |
| 9 | + |
| 10 | +{# |
| 11 | + We call a macro which calls itself to render the full tree. |
| 12 | + @see http://twig.sensiolabs.org/doc/tags/macro.html |
| 13 | +#} |
| 14 | +{{ menus.menu_links(items, attributes, 0) }} |
| 15 | + |
| 16 | +{% macro menu_links(items, attributes, menu_level) %} |
| 17 | + {% import _self as menus %} |
| 18 | + {% if items %} |
| 19 | + {% if menu_level == 0 %} |
| 20 | + <ul{{ attributes.addClass('nav navbar-nav justify-content-end ')|without('id') }}> |
| 21 | + {% else %} |
| 22 | + <ul class="dropdown-menu"> |
| 23 | + {% endif %} |
| 24 | + {% for item in items %} |
| 25 | + {% |
| 26 | + set classes = [ |
| 27 | + menu_level ? 'dropdown-item' : 'nav-item', |
| 28 | + item.is_expanded ? 'menu-item--expanded', |
| 29 | + item.is_collapsed ? 'menu-item--collapsed', |
| 30 | + item.in_active_trail ? 'active', |
| 31 | + item.below ? 'dropdown', |
| 32 | + ] |
| 33 | + %} |
| 34 | + <li{{ item.attributes.addClass(classes) }}> |
| 35 | + {% |
| 36 | + set link_classes = [ |
| 37 | + not menu_level ? 'nav-link', |
| 38 | + item.in_active_trail ? 'active', |
| 39 | + item.below ? 'dropdown-toggle', |
| 40 | + item.url.getOption('attributes').class ? item.url.getOption('attributes').class | join(' '), |
| 41 | + 'nav-link-' ~ item.url.toString() | clean_class, |
| 42 | + ] |
| 43 | + %} |
| 44 | + {% if item.below %} |
| 45 | + {{ link(item.title, item.url, {'class': link_classes, 'data-bs-toggle': 'dropdown', 'aria-expanded': 'false', 'aria-haspopup': 'true' }) }} |
| 46 | + {{ menus.menu_links(item.below, attributes, menu_level + 1) }} |
| 47 | + {% else %} |
| 48 | + {{ link(item.title, item.url, {'class': link_classes}) }} |
| 49 | + {% endif %} |
| 50 | + </li> |
| 51 | + {% endfor %} |
| 52 | + </ul> |
| 53 | + {% endif %} |
| 54 | +{% endmacro %} |
0 commit comments