{% load common_tags %}
{% load navigation_tags %}

{% if link|common_get_type == "<class 'mayan.apps.navigation.menus.Menu'>" %}
    <li class="dropdown">
        <a
            aria-haspopup="true" aria-expanded="true" class="dropdown-toggle"
            data-toggle="dropdown" href="#" role="button"
            {% if link.title %}title="{{ link.title }}"{% endif %}
        >
            {% navigation_link_get_icon link=link as link_icon %}

            {% if link_icon %}{{ link_icon.render }}{% endif %}
            {{ link.label|default:'' }}
            <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
            {% navigation_resolve_menu name=link.name as sub_menus_results %}
            {% for sub_menu_results in sub_menus_results %}
                {% for link_group in sub_menu_results.link_groups %}
                    {% with '' as li_class_active %}
                    {% with link_group.links as object_navigation_links %}
                        {% include 'navigation/generic_navigation.html' %}
                    {% endwith %}
                    {% endwith %}
                {% endfor %}
            {% endfor %}
        </ul>
    </li>
{% else %}
    {% if as_li %}
        <li class="{% if link.active and li_class_active %}{{ li_class_active }}{% endif %}">
    {% endif %}
        {% include link_template|default:'navigation/generic_link_instance.html' %}
    {% if as_li %}
        </li>
    {% endif %}
{% endif %}
