tools (common/template): add jid_resource filter
This commit is contained in:
parent
de6c050db2
commit
2cfe6c7a82
1 changed files with 5 additions and 0 deletions
|
|
@ -501,6 +501,7 @@ class Renderer:
|
|||
# custom filters
|
||||
self.env.filters["initials"] = self._initials
|
||||
self.env.filters["bare_jid"] = self._bare_jid
|
||||
self.env.filters["jid_resource"] = self._jid_resource
|
||||
self.env.filters["next_gidx"] = self._next_gidx
|
||||
self.env.filters["cur_gidx"] = self._cur_gidx
|
||||
self.env.filters["date_fmt"] = self._date_fmt
|
||||
|
|
@ -804,6 +805,10 @@ class Renderer:
|
|||
"""Return the bare JID"""
|
||||
return str(jid.JID(str(full_jid)).bare)
|
||||
|
||||
def _jid_resource(self, full_jid: str | jid.JID) -> str:
|
||||
"""Return the resource part of the JID"""
|
||||
return jid.JID(str(full_jid)).resource or ""
|
||||
|
||||
def _initials(self, name: str) -> str:
|
||||
"""Return the uppercased initials of a name."""
|
||||
name_parts = name.strip().split()
|
||||
|
|
|
|||
Loading…
Reference in a new issue