{% assign sub-nav-tabs = site.data.sidebar-nav.pages %} {% if sub-nav-tabs %}

{% assign page-base =  page.url | split:'/' %}
{% for each in sub-nav-tabs %}
    {% for each-url in each.urls %}
        {% if each-url == page.url %}
            {% if each.list %}
                {% assign tab-list = each.list %}
            {% endif %}
        {% elsif each.sub-pages-enabled %}
            {% if page.url contains each-url %}
                {% assign tab-list = each.list %}
            {% endif %}
        {% endif %}
    {% endfor %}
    {% if each.custom-include %}
        {% assign custom-include = each.custom-include %}
    {% endif %}
{% endfor %}
{% if tab-list %}
    <ul class="nav nav-pills nav-stacked" id="stacked-nav">
        {% for tab in tab-list %}
            <li class="{% if page-base[1] == tab.base  %}active {% elsif page.url == tab.url or tab.active %}active {% endif %}side-nav-button">
                <a href="{{tab.url}}" role="link">
                    {% if tab.icon %}
                    <div class="ext-left">
                        <img src="{{tab.icon}}" class="developer-services-icon" alt="{{tab.title}} Icon"/>
                    </div>
                    <div class="ext-right">
                        {{ tab.title}} {% if tab.external %}<i class="glyphicon glyphicon-new-window pull-right"></i>{% endif %}
                    </div>
                    {% else %}
                        {{ tab.title}} {% if tab.external %}<i class="glyphicon glyphicon-new-window pull-right"></i>{% endif %}
                    {% endif %}
                </a>
            </li>
            {% if tab.sub-tabs %}
                {% for sub-tab in tab.sub-tabs %}
                    <li class="{% if page-base[2] == sub-tab.base  %}active {% elsif page.url == sub-tab.url or sub-tab.active %}active {% endif %}side-nav-button sub-page">
                        <a href="{{sub-tab.url}}" role="link">
                            {{ sub-tab.title}} {% if sub-tab.external %}<i class="glyphicon glyphicon-new-window pull-right"></i>{% endif %}
                        </a>
                    </li>
                {% endfor %}
            {% endif %}
        {% endfor %}
    </ul>
{% elsif custom-include %}
    {% include {{custom-include}}.html %}
{% else %}
    No sidebar content found - please add to _data/sidebar-nav.yml. More information available <a href="/jekyll/includes/sidebar/">here</a>.
{% endif %}

{% else %}

No sidebar settings found - please create a _data/sidebar-nav.yml data file. More information available <a href="/jekyll/includes/sidebar/">here</a>.

{% endif %}