Skip to content

Commit

Permalink
Add dict_item template filter back (we need it for #960)
Browse files Browse the repository at this point in the history
  • Loading branch information
blms committed Dec 19, 2023
1 parent 4b00998 commit 239c173
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apps/readux/templatetags/readux_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
register = Library()


@register.filter
def dict_item(dictionary, key):
"""'Template filter to allow accessing dictionary value by variable key.
Example use::
{{ mydict|dict_item:keyvar }}
"""
# adapted from Princeton-CDH/geniza project https://github.com/Princeton-CDH/geniza/
try:
return dictionary[key]
except AttributeError:
# fail silently if something other than a dict is passed
return None

@register.filter
def has_inner_hits(volume):
"""Template filter to determine if there are any inner hits across the volume"""
Expand Down

0 comments on commit 239c173

Please sign in to comment.