Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / toolbar / templates / menu--toolbar.html.twig
1 {#
2 /**
3  * @file
4  * Default theme implementation to display a toolbar menu.
5  *
6  * Available variables:
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.
14  *   - is_expanded: TRUE if the link has visible children within the current
15  *     menu tree.
16  *   - is_collapsed: TRUE if the link has children within the current menu tree
17  *     that are not currently visible.
18  *   - in_active_trail: TRUE if the link is in the active trail.
19  *
20  * @ingroup themeable
21  */
22 #}
23 {% import _self as menus %}
24
25 {#
26   We call a macro which calls itself to render the full tree.
27   @see http://twig.sensiolabs.org/doc/tags/macro.html
28 #}
29 {{ menus.menu_links(items, attributes, 0) }}
30
31 {% macro menu_links(items, attributes, menu_level) %}
32   {% import _self as menus %}
33   {% if items %}
34     {% if menu_level == 0 %}
35       <ul{{ attributes.addClass('toolbar-menu') }}>
36     {% else %}
37       <ul class="toolbar-menu">
38     {% endif %}
39     {% for item in items %}
40       {%
41         set classes = [
42           'menu-item',
43           item.is_expanded ? 'menu-item--expanded',
44           item.is_collapsed ? 'menu-item--collapsed',
45           item.in_active_trail ? 'menu-item--active-trail',
46         ]
47       %}
48       <li{{ item.attributes.addClass(classes) }}>
49         {{ link(item.title, item.url) }}
50         {% if item.below %}
51           {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
52         {% endif %}
53       </li>
54     {% endfor %}
55     </ul>
56   {% endif %}
57 {% endmacro %}