{% comment %}
    Includes the cradmin menu. You can make your view not render the menu by
    setting the ``cradmin_hide_menu`` context variable to ``True``.
{% endcomment %}
{% load i18n %}

{% if not cradmin_hide_menu %}
    <nav id="cradmin_menu" ng-controller="CradminMenuController">
        {% block pre-menu %}{% endblock pre-menu %}

        <div class="cradmin_menumobileheader">
            <button type="button" class="btn btn-default cradmin_menutoggle"
                    ng-click="toggleNavigation()">
                <span class="sr-only">{% trans "Toggle navigation" %}</span>
                <span class="fa fa-bars"></span>
            </button>
        </div>

        <div class="cradmin_menucontent"
                ng-class="{cradmin_menucontent_display: displayMenu}">
            {% block menucontent %}
                {% with menu=request.cradmin_instance.get_menu %}
                    {% if menu.headeritems %}
                        <ul class="cradmin_menucontent_header">
                            {% for menuitem in menu.headeritems %}
                                {{ menuitem.render|safe }}
                            {% endfor %}
                        </ul>
                    {% endif %}
                    {% if menu.mainitems %}
                        <ul class="cradmin_menucontent_main">
                            {% for menuitem in menu.mainitems %}
                                {{ menuitem.render|safe }}
                            {% endfor %}
                        </ul>
                    {% endif %}
                    {% if menu.footeritems %}
                        <ul class="cradmin_menucontent_footer">
                            {% for menuitem in menu.footeritems %}
                                {{ menuitem.render|safe }}
                            {% endfor %}
                        </ul>
                    {% endif %}
                {% endwith %}
            {% endblock menucontent %}
        </div>

        {% block post-menu %}{% endblock post-menu %}
    </nav>
{% endif %}
