{% load i18n %}
{% load static %}

{% load unicms_contexts %}
{% load unicms_menus %}


{% if title %}
<h4>{{ title }}</h4>
<hr />
{% endif %}

{% for item in items %}

    {% call obj=item method='link' request=request as link %}

    {% with has_childs=item.get_childs %}

    <li style="list-style: none" {% if item.get_childs %}class="mt-2 mb-4"{% endif %}>
        {% if has_childs %}
            <b>
        {% endif %}

        <a href={% if item.link %}"{{ link }}"{% else %}"#"{% endif %}>
            <span>{{ item.name }}</span>
        </a>

        {% if has_childs %}
            <a class="list-item large medium right-icon"
               href="#collapse-{{item.id}}-{{ forloop.counter }}"
               data-toggle="collapse"
               aria-expanded="false"
               aria-controls="collapseOne">
                <svg class="icon icon-sm icon-secondary right" aria-hidden="true">
                    <use xlink:href="{% static 'svg/sprite.svg' %}#it-expand"></use>
                </svg>
            </a>
            {% load_item_childs item as childs %}
            </b>
            </li>
            <ul class="link-sublist collapse pl-1" id="collapse-{{item.id}}-{{ forloop.counter }}">
            {% for child in childs %}
                {% call obj=child method='link' request=request as child_link %}
                <li style="list-style: none">
                    <a class="list-item" href="{{ child_link}}">
                        <span class="text-dark">{{ child.name }}</span>
                    </a>
                </li>
            {% endfor %}
            </ul>
        {% else %}
    </li>
        {% endif %}

    {% endwith %}
{% endfor %}
