4 * Default theme implementation to display a menu.
7 * - menu_name: The machine name of the menu.
8 * - items: A nested list of menu items. Each menu item contains:
9 * - attributes: HTML attributes for the menu item.
10 * - below: The menu item child items.
11 * - title: The menu link title.
12 * - url: The menu link url, instance of \Drupal\Core\Url
13 * - localized_options: Menu link localized options.
18 {% import _self as menus %}
21 We call a macro which calls itself to render the full tree.
22 @see http://twig.sensiolabs.org/doc/tags/macro.html
24 {{ menus.menu_links(items, attributes, 0) }}
26 {% macro menu_links(items, attributes, menu_level) %}
27 {% import _self as menus %}
29 {% if menu_level == 0 %}
30 <ul{{ attributes.addClass('menu', 'nav', 'navbar-nav', 'navbar-right') }}>
32 <ul{{ attributes.addClass('dropdown-menu') }}>
34 {% for item in items %}
37 item.is_expanded? 'expanded',
38 item.is_expanded and menu_level == 0 ? 'dropdown',
39 item.in_active_trail ? 'active',
42 {% if menu_level == 0 and item.is_expanded %}
43 <li{{ item.attributes.addClass(item_classes) }}>
44 <a href="{{ item.url }}" class="dropdown-toggle" data-target="#" data-toggle="dropdown">{{ item.title }} <span class="caret"></span></a>
46 <li{{ item.attributes.addClass(item_classes) }}>
47 {{ link(item.title, item.url) }}
50 {{ menus.menu_links(item.below, attributes.removeClass('nav', 'navbar-nav', 'navbar-right'), menu_level + 1) }}