aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/templatetags/dict_utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/templatetags/dict_utils.py b/tools/templatetags/dict_utils.py
new file mode 100644
index 0000000..5a81c79
--- /dev/null
+++ b/tools/templatetags/dict_utils.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+#
+# utilities to deal with dictionary in template
+#
+
+from django import template
+
+
+register = template.Library()
+
+@register.filter
+def dictkey(d, key):
+ try:
+ value = d[key]
+ except KeyError:
+ from django.conf import settings
+ value = settings.TEMPLATE_STRING_IF_INVALID
+ return value
+