diff --git a/libervia/backend/tools/common/template.py b/libervia/backend/tools/common/template.py index f0bd11a0..da43d8f9 100644 --- a/libervia/backend/tools/common/template.py +++ b/libervia/backend/tools/common/template.py @@ -49,6 +49,7 @@ from libervia.backend.core.i18n import _ from libervia.backend.core.log import getLogger from libervia.backend.tools import config from libervia.backend.tools.common import date_utils +from libervia.frontends.tools import jid log = getLogger(__name__) @@ -469,6 +470,7 @@ class Renderer(object): self.env.globals["C"] = C # custom filters + self.env.filters["bare_jid"] = self._bare_jid self.env.filters["next_gidx"] = self._next_gidx self.env.filters["cur_gidx"] = self._cur_gidx self.env.filters["date_fmt"] = self._date_fmt @@ -758,6 +760,10 @@ class Renderer(object): return os.path.join(site_root_dir, C.TEMPLATE_TPL_DIR, template_data.theme, relative_url) + def _bare_jid(self, full_jid: str|jid.JID) -> str: + """Return the bare JID""" + return str(jid.JID(str(full_jid)).bare) + @pass_context def _next_gidx(self, ctx, value): """Use next current global index as suffix"""