{% extends "layout.html" %}

{# Macro for creating navigation links #}
{% macro render_navigation(pagination, endpoint) %}
    <div class=pagination>
        {% for page in pagination.iter_pages() %}
            {% if page %}
                {% if page != pagination.page %}
                    <a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a>
                {% else %}
                    <strong>{{ page }}</strong>
                {% endif %}
            {% else %}
                <span class=ellipsis>…</span>
            {% endif %}
        {% endfor %}
    </div>
{% endmacro %}

{% block body %}

<div class="todos">
    <ul>
        {% for todo in todos_page.items %}
            <li>{{ todo.title }}</li>
        {% endfor %}
    </ul>
</div>

<div class="navigation">
    {{ render_navigation(todos_page, 'pagination') }}
</div>


{% endblock %}
