Skip to content
This repository was archived by the owner on Apr 17, 2021. It is now read-only.

Commit 4ad9696

Browse files
committed
Add extra_pager_classes option to mirror the additional option in Pagination tag
1 parent 675f5f5 commit 4ad9696

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ simply provides a Previous and Next link.
209209
URL referenced by **url_view_name**. This allows us to use pretty
210210
pagination URLs such as "/page/1"
211211
- **url_anchor** - The anchor to use in URLs. Defaults to None
212+
- *extra_pager_classes* - A space separated list of CSS class names that will be added
213+
to the top level <ul> HTML element. This could be used to, as an
214+
example, add a class to prevent the pager from showing up when
215+
printing.
212216

213217
**Usage**
214218

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ url_extra_kwargs
232232
url_anchor
233233
The anchor to use in URLs. Defaults to None.
234234

235+
extra_pager_classes
236+
A space separated list of CSS class names that will be added to the top level
237+
<ul> HTML element. This could be used to, as an example, add a class to
238+
prevent the pager from showing up when printing.
239+
235240
**Usage**
236241

237242
Usage is basically the same as for bootstrap_paginate. The simplest usage is:

bootstrap_pagination/templates/bootstrap_pagination/pager.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ul class="pager">
1+
<ul class="pager {{ extra_pager_classes }}">
22
{% if page.has_previous %}
33
<li{% if not centered %} class="previous"{% endif %}>
44
<a title="{{ previous_title }}" href="{{ previous_page_url|default:"#"|escape }}">{{ previous_label }}</a>

bootstrap_pagination/templatetags/bootstrap_pagination.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def render(self, context):
131131
url_get_params = kwargs.get("url_get_params", context['request'].GET)
132132
url_anchor = kwargs.get("url_anchor", None)
133133

134+
extra_pager_classes = kwargs.get("extra_pager_classes", "")
135+
134136
previous_page_url = None
135137
if page.has_previous():
136138
previous_page_url = get_page_url(page.previous_page_number(), get_current_app(context), url_view_name, url_extra_args, url_extra_kwargs, url_param_name, url_get_params, url_anchor)
@@ -147,7 +149,8 @@ def render(self, context):
147149
'previous_title': previous_title,
148150
'next_title': next_title,
149151
'previous_page_url': previous_page_url,
150-
'next_page_url': next_page_url
152+
'next_page_url': next_page_url,
153+
'extra_pager_classes': extra_pager_classes,
151154
}))
152155

153156

@@ -419,6 +422,12 @@ def bootstrap_pager(parser, token):
419422
filters.
420423
421424
url_anchor - The anchor to use in URLs. Defaults to None.
425+
426+
extra_pager_classes - A space separated list of CSS class names
427+
that will be added to the top level <ul>
428+
HTML element. This could be used to,
429+
as an example, add a class to prevent
430+
the pager from showing up when printing.
422431
"""
423432
bits = token.split_contents()
424433
if len(bits) < 2:

tests/test_pager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ def test_example(self):
3131
c = Context({'page_obj': paginator.page(2),
3232
'request': django.http.HttpRequest()})
3333
html = lxml.html.fragment_fromstring(template.render(c))
34-
self.assertEqual(html.get('class'), 'pager')
34+
self.assertEqual(html.get('class').strip(), 'pager')

0 commit comments

Comments
 (0)