Add a remove_item template filter.
[matthijs/projects/xerxes.git] / tools / templatetags / misc.py
1 from django import template
2
3 """
4     Miscellaneous template tags and filters.
5 """
6
7 register = template.Library()
8 @register.filter(name='remove_item')
9 def remove_item(container, item):
10     """
11     Removes the given user from the filtered list or dict.
12     """
13     if (item in container):
14         if isinstance(container, list):
15             container.remove(item)
16         elif isinstance(container, dict):
17             container.pop(item)
18     return container
19
20 # vim: set sts=4 sw=4 expandtab: