{% macro minimal_li(v) %}
    {{ v.minimal.render }}
{% endmacro %}

{% macro external_li(v) %}
    <li><a href="{{ v.external }}">{{ v.tab_label | capitalize }}</a></li>
{% endmacro %}

{% macro static_li(v) %}
    <li class="{{ v.label }}">{{ v.static.renderable() }}</li>
{% endmacro %}

{% macro independent_li(v) %}
    <li class="{{ v.label }}">{{ v.independent.render }}</li>
{% endmacro %}

{% macro content_li(v) %}
    <li><a href="#{{ v.label }}" data-toggle="tab">{{ v.tab_label | capitalize }}</a></li>
{% endmacro %}

{% macro _tabs_navigation(groups) %}
    {% for g, v in groups.items() %}
        {{ v._li(v) | safe }}
    {% endfor %}
{% endmacro %}

{% macro _tabs_content(groups) %}
    {% for g, content in groups.items() %}
        {% if content.content %}
            {{ _tab_content(content) }}
        {% endif %}
    {% endfor %}
{% endmacro %}

{% macro _tab_content(content) %}
    <div id="{{ content['label'] }}" class="tab-pane">
        {{ content.content.render | safe }} 
    </div>
{% endmacro %}

{% macro bootstrap_tabs(t) %}
    <div class={{ t.tabset_css_class }}>
        <ul class="nav {% if t.pills %} nav-pills{% else %} nav-tabs{% endif %}{% if t.justified %} nav-justified{% endif %}{% if t.vertical %} nav-stacked{% endif %}">
            {{ _tabs_navigation(t.tab_groups) }}
        </ul>
        <div class="tab-content">
            {{ _tabs_content(t.tab_groups)}}
        </div>
    </div>
{% endmacro %}

{% macro minimal_tabs(t) %}
    <tabset class={{ t.tabset_css_class }}{%if t.vertical%} vertical="true"{% endif %}{% if t.justified %} justified="true"{% endif %}>
        {% for k,v in t.tab_groups.items() %}
            {% if v.kind in ('minimal', 'external', 'static', 'independent') %}
                {{ v._li(v) | safe}}
            {% else %}
                <tab heading={{v['label']}}>{{ v.content.render | safe }}</tab>
            {% endif %}
        {% endfor %}
    </tabset>
{% endmacro %}
