{% 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 %}