diff libervia/backend/tools/common/template.py @ 4081:84f6bee6440d

installation: moved from `setup.py` to `pyproject.toml`: - updated installation to use the now standard `pyproject.toml` instead of legacy `setup.py`. `setup.py` and other legacy files have been deleted. - removed outdated README4PACKAGERS - removed pylintrc which has not been correctly reviewed. Linter conf should go to `pyproject.toml` now. - [hatch](https://hatch.pypa.io) is now used as main building tool. However, thanks to the use of standards, other tools can be used too. - update .hgignore - several dependencies version bump, with code update to adapt to changes.
author Goffi <goffi@goffi.org>
date Tue, 06 Jun 2023 16:45:16 +0200
parents 47401850dec6
children f742f28b3934
line wrap: on
line diff
--- a/libervia/backend/tools/common/template.py	Tue Jun 06 13:42:00 2023 +0200
+++ b/libervia/backend/tools/common/template.py	Tue Jun 06 16:45:16 2023 +0200
@@ -61,11 +61,11 @@
     )
 
 from lxml import etree
-from jinja2 import Markup as safe
+from markupsafe import Markup as safe
 from jinja2 import is_undefined
 from jinja2 import utils
 from jinja2 import TemplateNotFound
-from jinja2 import contextfilter
+from jinja2 import pass_context
 from jinja2.loaders import split_template_path
 
 HTML_EXT = ("html", "xhtml")
@@ -736,7 +736,7 @@
 
     ## custom filters ##
 
-    @contextfilter
+    @pass_context
     def _front_url(self, ctx, relative_url):
         """Get front URL (URL seen by end-user) from a relative URL
 
@@ -752,13 +752,13 @@
         return os.path.join(site_root_dir, C.TEMPLATE_TPL_DIR, template_data.theme,
                             relative_url)
 
-    @contextfilter
+    @pass_context
     def _next_gidx(self, ctx, value):
         """Use next current global index as suffix"""
         next_ = ctx["gidx"].next(value)
         return value if next_ == 0 else "{}_{}".format(value, next_)
 
-    @contextfilter
+    @pass_context
     def _cur_gidx(self, ctx, value):
         """Use current current global index as suffix"""
         current = ctx["gidx"].current(value)
@@ -821,7 +821,7 @@
                 continue
         return " ".join(classes) or None
 
-    @contextfilter
+    @pass_context
     def _item_filter(self, ctx, item, filters):
         """return item's value, filtered if suitable
 
@@ -847,7 +847,7 @@
                 kwargs = filters_args[idx] if filters_args is not None else {}
                 filter_func = self.env.filters[f_name]
                 try:
-                    eval_context_filter = filter_func.evalcontextfilter
+                    eval_context_filter = filter_func.evalpass_context
                 except AttributeError:
                     eval_context_filter = False