{% macro renderMenu(title, icon, items) %}
    {% set my_routes = [] %}
    {% for item in items %}
        {% set my_routes = my_routes|merge([item.route.name]) %}
    {% endfor %}
    <div class="item">
        <div class="image header title{% if cur_route in my_routes %} active{% endif %}">
            <i class="{{ icon }} icon"></i>
            {{ title }}
            <i class="dropdown icon"></i>
        </div>
        <div class="content{% if cur_route in my_routes %} active{% endif %}">
            {% for item in items %}
                {{ _self.renderMenuItem(item.label, item.title, item.route, item.icon ?? null) }}
            {% endfor %}
        </div>
    </div>
{% endmacro %}

{% macro renderMenuItem(label, title, route, icon, class, tips_position) %}
    {% if class is empty %}
        {% if is_current_url(route.name, route.args|default([])) %}
            {% set class = "active item" %}
        {% else %}
            {% set class = "item" %}
        {% endif %}
    {% endif %}
    <a
            href="{{ url_for(route.name, route.args|default([])) }}"
            class="{{ class }}"
            title="{{ title }}"
            {% if tips_position %}data-position="{{ tips_position }}"{% endif %}
    >
        {% if icon %}
            <i class="{{ icon }} icon" aria-hidden="true"></i>
        {% endif %}
        {{ label }}
    </a>
{% endmacro %}
