Mercurial > piecrust2
comparison piecrust/templating/jinjaengine.py @ 352:498a917cd2d4
pagination: Make pagination use routes to generate proper URLs.
This fixes incorrect URLs when using custom sub-page suffixes, for instance.
Add tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 17 Apr 2015 16:09:30 -0700 |
parents | 938be93215cb |
children | 019d274e6713 |
comparison
equal
deleted
inserted
replaced
351:1f22d4b10fef | 352:498a917cd2d4 |
---|---|
177 cpi = self.app.env.exec_info_stack.current_page_info | 177 cpi = self.app.env.exec_info_stack.current_page_info |
178 if cpi is None or cpi.page is None or cpi.render_ctx is None: | 178 if cpi is None or cpi.page is None or cpi.render_ctx is None: |
179 raise Exception("Can't paginate when no page has been pushed " | 179 raise Exception("Can't paginate when no page has been pushed " |
180 "on the execution stack.") | 180 "on the execution stack.") |
181 first_uri, _ = split_sub_uri(self.app, cpi.render_ctx.uri) | 181 first_uri, _ = split_sub_uri(self.app, cpi.render_ctx.uri) |
182 return Paginator(cpi.page, value, first_uri, | 182 return Paginator(cpi.page, value, |
183 page_num=cpi.render_ctx.page_num, | 183 page_num=cpi.render_ctx.page_num, |
184 items_per_page=items_per_page) | 184 items_per_page=items_per_page) |
185 | 185 |
186 def _formatWith(self, value, format_name): | 186 def _formatWith(self, value, format_name): |
187 return format_text(self.app, format_name, value) | 187 return format_text(self.app, format_name, value) |
188 | 188 |
189 | 189 |