diff piecrust/templating/jinjaengine.py @ 298:b7ab1b503510

data: Fix incorrect next/previous page URLs in pagination data. Consolidate splitting an URL between its first URL and its sub page number. Be careful about the index page's URL not losing its slash.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 11 Mar 2015 23:46:42 -0700
parents d013cc191922
children 1ecc0c16ba64
line wrap: on
line diff
--- a/piecrust/templating/jinjaengine.py	Tue Mar 10 08:34:45 2015 -0700
+++ b/piecrust/templating/jinjaengine.py	Wed Mar 11 23:46:42 2015 -0700
@@ -18,7 +18,7 @@
 from piecrust.routing import CompositeRouteFunction
 from piecrust.templating.base import (TemplateEngine, TemplateNotFoundError,
                                       TemplatingError)
-from piecrust.uriutil import multi_replace, get_first_sub_uri
+from piecrust.uriutil import multi_replace, split_sub_uri
 
 
 logger = logging.getLogger(__name__)
@@ -176,7 +176,7 @@
         if cpi is None or cpi.page is None or cpi.render_ctx is None:
             raise Exception("Can't paginate when no page has been pushed "
                             "on the execution stack.")
-        first_uri = get_first_sub_uri(self.app, cpi.render_ctx.uri)
+        first_uri, _ = split_sub_uri(self.app, cpi.render_ctx.uri)
         return Paginator(cpi.page, value, first_uri,
                 page_num=cpi.render_ctx.page_num,
                 items_per_page=items_per_page)