# HG changeset patch # User Goffi # Date 1537296958 -7200 # Node ID 39d187f3698d9d5e2b2e3ca9a4e019f7927635ca # Parent 60c9e163f1df6890e366d9802e74649908524701 template: import contextfilter as module attribute diff -r 60c9e163f1df -r 39d187f3698d sat/tools/common/template.py --- a/sat/tools/common/template.py Tue Sep 18 20:53:50 2018 +0200 +++ b/sat/tools/common/template.py Tue Sep 18 20:55:58 2018 +0200 @@ -59,6 +59,7 @@ 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 @@ 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 @@ ## 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 @@ 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 @@ continue return u" ".join(classes) or None - @jinja2.contextfilter + @contextfilter def _item_filter(self, ctx, item, filters): """return item's value, filtered if suitable