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

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

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