template: import contextfilter as module attribute
This commit is contained in:
parent
da424c4440
commit
0a7a2a0902
1 changed files with 5 additions and 5 deletions
|
|
@ -59,6 +59,7 @@ from jinja2 import Markup as safe
|
|||
from jinja2 import is_undefined
|
||||
from jinja2 import utils
|
||||
from jinja2 import TemplateNotFound
|
||||
from jinja2 import contextfilter
|
||||
from jinja2.loaders import split_template_path
|
||||
from lxml import etree
|
||||
|
||||
|
|
@ -327,7 +328,6 @@ class Renderer(object):
|
|||
Only set to True if environment is safe (e.g. command line tool)
|
||||
@param private(bool): if True, also load sites from sites_path_private_dict
|
||||
"""
|
||||
# TODO:
|
||||
self.host = host
|
||||
self.trusted = trusted
|
||||
self.sites_paths = {
|
||||
|
|
@ -582,7 +582,7 @@ class Renderer(object):
|
|||
|
||||
## custom filters ##
|
||||
|
||||
@jinja2.contextfilter
|
||||
@contextfilter
|
||||
def _front_url(self, ctx, relative_url):
|
||||
"""Get front URL (URL seen by end-user) from a relative URL
|
||||
|
||||
|
|
@ -598,13 +598,13 @@ class Renderer(object):
|
|||
return os.path.join(site_root_dir, C.TEMPLATE_TPL_DIR, template_data.theme,
|
||||
relative_url)
|
||||
|
||||
@jinja2.contextfilter
|
||||
@contextfilter
|
||||
def _next_gidx(self, ctx, value):
|
||||
"""Use next current global index as suffix"""
|
||||
next_ = ctx["gidx"].next(value)
|
||||
return value if next_ == 0 else u"{}_{}".format(value, next_)
|
||||
|
||||
@jinja2.contextfilter
|
||||
@contextfilter
|
||||
def _cur_gidx(self, ctx, value):
|
||||
"""Use current current global index as suffix"""
|
||||
current = ctx["gidx"].current(value)
|
||||
|
|
@ -653,7 +653,7 @@ class Renderer(object):
|
|||
continue
|
||||
return u" ".join(classes) or None
|
||||
|
||||
@jinja2.contextfilter
|
||||
@contextfilter
|
||||
def _item_filter(self, ctx, item, filters):
|
||||
"""return item's value, filtered if suitable
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue