{% macro nav_loop(page) %}
  {% import _self as macros %}
  {% for p in page.children.visible %}
    {% set active_page = (p.active or p.activeChild) ? ' class="active"' : '' %}
    {% if p.children.visible.count > 0 %}
      <li>
        <a href="{{ p.url }}"{{ active_page }}>
          {{ p.menu }}
        </a>
        <ul>
          {{ macros.nav_loop(p) }}
        </ul>
      </li>
    {% else %}
      <li>
        <a href="{{ p.url }}"{{ active_page }}>
          {{ p.menu }}
        </a>
      </li>
    {% endif %}
  {% endfor %}
{% endmacro %}
