Skip to content

Commit

Permalink
Fix rendering of pagination widget in Jinja 2.9.
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeldycke committed Jan 14, 2017
1 parent 0396034 commit 2154603
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions templates/pagination.html
Expand Up @@ -17,9 +17,12 @@
</li>
{% endif %}

{% set is_previous_ellipsis = False -%}
{% for num in range(1, articles_paginator.num_pages + 1) %}
{% if num in [1, 2, articles_page.number - 1, articles_page.number, articles_page.number + 1, articles_paginator.num_pages - 1, articles_paginator.num_pages] %}
{% for num in articles_paginator.page_range %}
{% set linked_pages = [
1, 2, articles_page.number - 1, articles_page.number,
articles_page.number + 1, articles_paginator.num_pages - 1,
articles_paginator.num_pages] %}
{% if num in linked_pages %}
{% set is_current_page = (num == articles_page.number) -%}
<li class="{{ 'active' if is_current_page else '' }}">
<a href="{{ SITEURL }}/{{ page_name }}{{ num if num > 1 else ''}}.html"
Expand All @@ -34,12 +37,8 @@
{% endif %}
</a>
</li>
{% set is_previous_ellipsis = False -%}
{% else %}
{% if not is_previous_ellipsis %}
<li class="disabled"><a></a></li>
{% endif %}
{% set is_previous_ellipsis = True -%}
{% elif (num - 1) in linked_pages %}
<li class="disabled"><a></a></li>
{% endif %}
{% endfor %}

Expand Down

0 comments on commit 2154603

Please sign in to comment.