Browse Source

Add {% get_setting %} template tag

Alexandre Macabies 8 years ago
parent
commit
7a3160bc2a
1 changed files with 20 additions and 0 deletions
  1. 20 0
      panorama/templatetags/utils.py

+ 20 - 0
panorama/templatetags/utils.py

@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django import template
+from django.conf import settings
+
+register = template.Library()
+
+
+@register.simple_tag
+def get_setting(name):
+    """
+    Example usage:
+        Contact us at {% get_setting 'CONTACT_EMAIL' %}
+    or
+        {% get_setting 'AMOUNT' as amount %}
+        Please pay {{ amount|add:42 }}
+    """
+    return getattr(settings, name, None)
+