<div class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container">

        <div class="navbar-header">
            <!-- Collapsed navigation button -->
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>

            <!-- Main title -->
            <a class="navbar-brand" href="{{ homepage_url }}">{{ site_name }}</a>
        </div>

        <div class="navbar-collapse collapse">
            <!-- Main navigation -->
            <ul class="nav navbar-nav">
            {% for nav_item in nav %}
            {% if nav_item.children %}
                <li class="dropdown{% if nav_item.active %} active{% endif %}">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ nav_item.title }} <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                    {% for nav_item in nav_item.children %}
                        <li {% if nav_item.active %}class="active"{% endif %}>
                            <a href="{{ nav_item.url }}">{{ nav_item.title }}</a>
                        </li>
                    {% endfor %}
                    </ul>
                </li>
            {% else %}
                <li {% if nav_item.active %}class="active"{% endif %}>
                    <a href="{{ nav_item.url }}">{{ nav_item.title }}</a>
                </li>
            {% endif %}
            {% endfor %}
            </ul>

            <!-- Additional navigation items -->
            <ul class="nav navbar-nav navbar-right">
                <li {% if not previous_page %}class="disabled"{% endif %}>
                    <a rel="next" {% if previous_page %}href="{{ previous_page.url }}"{% endif %}>Previous</a>
                </li>
                <li {% if not next_page %}class="disabled"{% endif %}>
                    <a rel="prev" {% if next_page %}href="{{ next_page.url }}"{% endif %}>Next</a>
                </li>
            </ul>
        </div>
    </div>
</div>
