From 632be3bd7073941e5df10a9bc45343c154a4ef95 Mon Sep 17 00:00:00 2001 From: Grey Li Date: Wed, 26 Apr 2017 18:50:22 +0800 Subject: [PATCH 1/4] Add support for URL section in pagination button When use this macro to paginate comments on a post page, you have to scroll to comment area every time after you click the page button. It is useful to add a URL section in page button, here is a simple use case: `render_pagination(pagination, section='#comment')`. --- flask_bootstrap/templates/bootstrap/pagination.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/flask_bootstrap/templates/bootstrap/pagination.html b/flask_bootstrap/templates/bootstrap/pagination.html index 63c22b30..2ab6c7ad 100644 --- a/flask_bootstrap/templates/bootstrap/pagination.html +++ b/flask_bootstrap/templates/bootstrap/pagination.html @@ -14,7 +14,8 @@ next=('»')|safe, size=None, ellipses='…', - args={} + args={}, + section=None ) -%} {% with url_args = {} %} @@ -26,13 +27,13 @@ From 8bb2a56703f94491edf9b9e3f2a16ffb086f79e5 Mon Sep 17 00:00:00 2001 From: Grey Li Date: Wed, 26 Apr 2017 19:00:15 +0800 Subject: [PATCH 2/4] Update SQLAlchemy docs for pagination URL section --- docs/sqlalchemy.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sqlalchemy.rst b/docs/sqlalchemy.rst index 709770b7..6a8a9be6 100644 --- a/docs/sqlalchemy.rst +++ b/docs/sqlalchemy.rst @@ -21,6 +21,7 @@ automatically rendered through the ``render_pagination`` macro: ellipses='…',\ size=None,\ args={},\ + section=None,\ **kwargs) Renders a pager for query pagination. @@ -39,5 +40,6 @@ automatically rendered through the ``render_pagination`` macro: :param size: Can be 'sm' or 'lg' for smaller/larger pagination. :param args: Additional arguments passed to :func:`~flask.url_for`. If ``endpoint`` is ``None``, uses :attr:`~flask.Request.args` and - :attr:`~flask.Request.view_args` + :attr:`~flask.Request.view_args`. + :param section: Add url section to link, such as ``#comment``. :param kwargs: Extra attributes for the ``