{%- set ns.limit = limit -%}
{%- if ns.limit == 0 or ns.limit == 10 -%}
{%- set ns.limit = None -%}
{%- endif -%}
{%- set ns.prev = start-limit -%}
{%- if ns.prev == 0-%}
{%- set ns.prev = None -%}
{%- endif -%}
{%- set ns.next = start+limit -%}
{%- if ns.next == 0-%}
{%- set ns.next = None -%}
{%- endif -%}
{%- set ns.start = start -%}
{%- if ns.start == 0-%}
{%- set ns.start = None -%}
{%- endif -%}
{%- set thispage = (start / limit)|round(0,'floor')|int + 1 -%}
{%- set totalpages = (ns.total / limit)|round(0,'ceil')|int -%}
{%- set ns.ellipsis = False -%}
{% if thispage > 1 %}
« First
{% if (start-limit) > 1 %}
< Prev
{% endif %}
{% endif %}
{% for page in range(1, totalpages+1) %}
{% if page < 4 or page > (totalpages+1-4) or (page > (thispage-3) and page < (thispage+3)) %}
{%- if page != thispage -%}
{{ page }}
{%- else -%}
{{ page }}
{%- endif %}
{%- set ns.ellipsis = False -%}
{%- else -%}
{%- if not ns.ellipsis -%}
…
{%- endif -%}
{%- set ns.ellipsis = True -%}
{% endif %}
{% endfor %}
{% if thispage < totalpages %}
{% if (start+limit) != (totalpages-1)*limit %}
Next >
{% endif %}
Last »
{% endif %}