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
{% macro menu(items, currentPath) %}
{% import _self as self %}
{% for menuItem in items %}
{% set url = menuItem.url %}
{% set attributes = "menuitem" %}
{% if menuItem.classAttribute %}
{% set attributes = attributes ~ ' ' ~ menuItem.classAttribute %}
{% endif %}
{% if menuItem.hasChild() %}
{% set attributes = attributes ~ ' has-child dropdown' %}
{% for childItem in menuItem.children %}
{% set childUrl = childItem.url %}
{% if childUrl == currentPath %}
{% set attributes = attributes ~ ' active current-parent' %}
{% endif %}
{% endfor %}
{% endif %}
<li class="nav-item {% if menuItem.hasChild() %}dropdown{% endif %}{{ attributes }}" role="menuitem">
{% if menuItem.hasChild() %}
<a href="#" id="navbarDropdown{{ menuItem.id }}" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link parent dropdown-toggle {% if currentPath == url %}current{% endif %}" {% if menuItem.target %} target="_blank"{% endif %}>{{ menuItem.name }}</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown{{ menuItem.id }}">
{{ self.menuchild(menuItem.children, currentPath) }}
</div>
{% else %}
<a href="{{ url }}" class="nav-link {% if currentPath == url %}current{% endif %}" {% if menuItem.target %} target="_blank"{% endif %}>{{ menuItem.name }}</a>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
{% macro menuchild(items, currentPath) %}
{% import _self as self %}
{% for menuItem in items %}
{% set url = menuItem.url %}
<a href="{{ url }}" class="dropdown-item {% if currentPath == url %}current{% endif %}" {% if menuItem.target %} target="_blank"{% endif %}>{{ menuItem.name }}</a>
{% endfor %}
{% endmacro %}