Mercurial > libervia-backend
changeset 4165:81faa85c9cfa
template: add a `bare_jid` filter
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 28 Nov 2023 17:41:49 +0100 |
parents | 15482dc0b5d1 |
children | a1f7040b5a15 |
files | libervia/backend/tools/common/template.py |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/backend/tools/common/template.py Tue Nov 28 17:41:02 2023 +0100 +++ b/libervia/backend/tools/common/template.py Tue Nov 28 17:41:49 2023 +0100 @@ -49,6 +49,7 @@ 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 @@ 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 @@ 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"""