macro pager page pages target_url for in range pages if page p-1 else

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{% macro pager(page, pages, target_url) -%}
{% for p in range(1, pages+1) %}
{% if page == p-1 %}
{{ p }}
{% else %}
<a href="{{ url target_url kwargs=kwargs }}">{{ p }}</a>
{% endif %}
{% endfor %}
{%- endmacro %}
{{ pager(10, 20, 'avatar.index' tag=tag param=10 foo=20 }}