Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{#
/**
* @file
* Theme override to display a menu.
*
* Available variables:
* - menu_name: The machine name of the menu.
* - items: A nested list of menu items. Each menu item contains:
* - attributes: HTML attributes for the menu item.
* - below: The menu item child items.
* - title: The menu link title.
* - url: The menu link url, instance of \Drupal\Core\Url
* - localized_options: Menu link localized options.
* - is_expanded: TRUE if the link has visible children within the current
* menu tree.
* - is_collapsed: TRUE if the link has children within the current menu tree
* that are not currently visible.
* - in_active_trail: TRUE if the link is in the active trail.
*/
#}
{% import _self as menus %}
{#
We call a macro which calls itself to render the full tree.
@see http://twig.sensiolabs.org/doc/tags/macro.html
#}
{{ menus.menu_links(items, attributes, 0, menu_class, menu_modifiers, menu_blockname, item_base_class, item_modifiers, item_blockname) }}
{% macro menu_links(items, attributes, menu_level, menu_class, menu_modifiers, menu_blockname, item_base_class, item_modifiers, item_blockname) %}
{% import _self as menus %}
{% if items %}
{# Set classes #}
{% set menu_class = menu_class|default('menu') %}
{% if not menu_modifiers %}
{% set menu_modifiers = [] %}
{% endif %}
{% if menu_level > 0 %}
{% set menu_modifiers = menu_modifiers|merge(['sub', 'sub-' ~ menu_level]) %}
{% endif %}
{# List #}
{% embed "@atoms/03-lists/00-ul.twig" with {
ul_base_class: menu_class,
ul_modifiers: menu_modifiers,
ul_blockname: menu_blockname
} %}
{% block list_content %}
{% for item in items %}
{% include "@molecules/menus/_menu-item.twig" with {
li_base_class: item_base_class,
li_modifiers: item_modifiers,
li_blockname: item_blockname,
} %}
{% endfor %}
{% endblock %}
{% endembed %}
{% endif %}
{% endmacro %}