{% macro render_page(page, active_page) %}
{% with active_class='active' if (page==active_page or active_page in page.children) or ''%}
{% set aria_current='aria-current="page"'|safe if page==active_page else "" %}
{% with page_html_id=page.slug %}
{% if page.children.all() %}
<li class="nav-item dropdown {{active_class}}">
<a {{ aria_current}} class="nav-link dropdown-toggle" href="#" id="{{ page_html_id }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{page.title}}</a>
<div class="dropdown-menu bg-dark" aria-labelledby="{{ page_html_id }}">
<a class="nav-link" href="{{ page_url(page) }}" {{aria_current}}>{{page.title}}</a>
{% for child in page.children %}
{% set aria_current='aria-current="page"'|safe if child==active_page else "" %}
<a class="dropdown-item bg-dark text-white {{active_class}}" href="{{ page_url(child) }}" {{ aria_current }} >{{child.title}}</a>
{% endfor %}
</div>
</li>
{% else %}
<li  class="nav-item {{active_class}}"><a {{ aria_current }} class="nav-link" href="{{page_url(page) }}">{{page.title}}</a></li>
{% endif %}
{% endwith %}
{% endwith %}
{% endmacro %}

{% macro render_tree_branch(branch) %}
<a href="{{ page_url(branch) }}" class="list-group-item list-group-item-action footer-tree-link text-white">{{branch.title}}</a>
{% if branch.children %}
<div class="list-group list-group-flush submenu">
{% for b in branch.children %}
{{render_tree_branch(b)}}
{% endfor %}
</div>
{% endif %}
{% endmacro %}

{% macro render_footer_tree(pages) %}
<hr />
{% endmacro %}
