分类: Python/Ruby
2021-07-29 17:26:18
{# This file was part of Flask-Bootstrap and was modified under the terms of
its BSD License. Copyright (c) 2013, Marc Brinkmann. All rights reserved. #}
{% macro render_pager(pagination,
fragment='',
prev=(' Previous')|safe,
next=('Next ')|safe,
align='') -%}
href="{{ url_for(request.endpoint, page=pagination.prev_num, **kwargs) + fragment if pagination.has_prev else '#' }}">
{{ prev }}
href="{{ url_for(request.endpoint, page=pagination.next_num, **kwargs) + fragment if pagination.has_next else '#' }}">
{{ next }}
{%- endmacro %}
{% macro _arg_url_for(endpoint, base) %}
{# calls url_for() with a given endpoint and **base as the parameters,
additionally passing on all keyword_arguments (may overwrite existing ones)
#}
{%- with kargs = base.copy() -%}
{%- do kargs.update(kwargs) -%}
{{ url_for(endpoint, **kargs) }}
{%- endwith %}
{%- endmacro %}
{% macro render_pagination(pagination,
endpoint=None,
prev=('?')|safe,
next=('?')|safe,
size=None,
ellipses='…',
args={},
fragment='',
align=''
)-%}
{% if fragment != '' and not fragment.startswith('#') %}{% set fragment = '#' + fragment %}{% endif %}
{% with url_args = {} %}
{%- do url_args.update(request.view_args if not endpoint else {}),
url_args.update(request.args if not endpoint else {}),
url_args.update(args) -%}
{% with endpoint = endpoint or request.endpoint %}
{# prev and next are only show if a symbol has been passed. #}
{% if prev != None -%}
{%- endif -%}
{%- for page in pagination.iter_pages() %}
{% if page %}
{% if page != pagination.page %}
{% else %}
{% endif %}
{% elif ellipses != None %}
{% endif %}
{%- endfor %}
{% if next != None -%}
{%- endif -%}
{% endwith %}
{% endwith %}
{% endmacro %}