{% 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-bs-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 %}
        {% if tav_env == 1 and menuItem.name == "Carte des prestataires" %}
            {% set name = "Carte des points de vente" %}
        {% elseif tav_env == 1 and menuItem.name == "Liste des prestataires" %}
            {% set name = "Liste des points de vente" %}
        {% else %}
            {% set name = menuItem.name %}
        {% endif %}
        <a href="{{ url }}" class="dropdown-item {% if currentPath == url %}current{% endif %}" {% if menuItem.target %} target="_blank"{% endif %}>{{ name }}</a>
    {% endfor %}
{% endmacro %}