add get_text
template filter
returns object's `content` or `name`, the first is set, or an empty string. some objects don't have `content`, don't let templates rely on it
This commit is contained in:
parent
a71bf46af5
commit
1f2a8f6da7
3 changed files with 12 additions and 4 deletions
|
@ -403,6 +403,14 @@ def get_video_link(data):
|
|||
return data
|
||||
return None
|
||||
|
||||
@filters.app_template_filter()
|
||||
def get_text(data):
|
||||
"""return first in 'content', 'name' or ''"""
|
||||
for _t in ("content", "name"):
|
||||
if _t in data:
|
||||
return data[_t]
|
||||
return ""
|
||||
|
||||
|
||||
@filters.app_template_filter()
|
||||
def has_type(doc, _types):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue