{% extends 'partials/base.html.twig' %}

{% macro loop(page) %}
    {% for p in page.children.visible %}
        {% set current_page = (p.active or p.activeChild) ? 'selected' : '' %}
        {% if p.children.visible.count > 0 %}
            <div class="has-children {{ current_page|e }}">
                    {# parent #}
                    <h2>{{ p.menu|e }}</h2>
                    {{ p.content|raw }}
                <div>
                    {{ _self.loop(p) }}
                </div>
            </div>
        {% else %}
            <div class="{{ current_page|e }}">
                    {# enfant #}
                    <h3>{{ p.menu|e }}</h3>
                    {{ p.content|raw }}
            </div>
        {% endif %}
    {% endfor %}
{% endmacro %}

{% block content %}
    {{ _self.loop(pages) }}
{% endblock %}
