Skip to content

Commit

Permalink
Added first draft of pagination macros.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbr committed Nov 4, 2014
1 parent a75962d commit 31fba9d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions flask_bootstrap/templates/bootstrap/pagination.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% macro render_pagination(pagination, endpoint, prev=('«')|safe, next=('»')|safe) %}
<nav>
<ul class="pagination"{{kwargs|xmlattr}}>
{% if prev %}<li {% if not pagination.has_prev %}class="disabled"{% endif %}><a href="{% if pagination.has_prev %}{{url_for(endpoint, page=pagination.prev_num)}}{% else %}#{% endif %}">{{prev}}</li></a>{% endif %}
{%- for page in pagination.iter_pages() %}
{% if page %}
{% if page != pagination.page %}
<li><a href="{{url_for(endpoint, page=page)}}">{{page}}</a></li>
{% else %}
<li class="active"><a href="#">{{page}} <span class="sr-only">(current)</span></a></li>
{% endif %}
{% else %}
<li class="disabled"><a href="#"></a></li>
{% endif %}
{%- endfor %}
{% if next %}<li {% if not pagination.has_next %}class="disabled"{% endif %}><a href="{% if pagination.has_next %}{{url_for(endpoint, page=pagination.next_num)}}{% else %}#{% endif %}">{{next}}</li></a>{% endif %}
</ul>
</nav>
{% endmacro %}

0 comments on commit 31fba9d

Please sign in to comment.