{# ::

Help extract the main title and the sub title for the active menu navigation
Useful to quickly bootstrap an admin

:: #}

{# :: Extract the main menu of the navigation :: #}
{% macro parent() %}
        {% for nav in __g.NAV_MENU %}
            {% set nav_name = nav[1] %}
            {% set nav_items = nav[2] %}
            {% set nav_kwargs = nav[3] %}

            {% if nav_kwargs["__active"] %}
                {{ nav_name }}
            {% endif %}
        {% endfor %}
{% endmacro %}


{# :: Extract the sub menu of the current endpoint navigation :: #}
{% macro child() %}
        {% for nav in __g.NAV_MENU %}
            {% set nav_name = nav[1] %}
            {% set nav_items = nav[2] %}
            {% set nav_kwargs = nav[3] %}
            {% set nav_items_hidden = nav[3]["__hidden"] %}

            {% if nav_kwargs["__active"] %}

              {% for item in nav_items_hidden %}
                  {% set item_name = item[1] %}
                  {% set item_endpoint = item[2] %}
                  {% if item_endpoint == request.endpoint %}
                    {{ item_name }}
                  {% endif %}
              {% endfor %}

            {% endif %}
        {% endfor %}
{% endmacro %}