summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-05-08 03:36:16 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-05-08 03:36:16 +0000
commitfaa31732caa17d942b05fd4e25c49bb0589ce76f (patch)
treeba6261d981bb1e583938838696da8e0e23ac3532 /django
parent77ec8ae811f0f9d6a55c570ee7c02c52e6e7bc8d (diff)
Fixed #3753 -- Allow optional display of invalid variable name in
TEMPLATE_STRING_IF_INVALID. Thanks, Matt McClanahan. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5167 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/template/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/django/template/__init__.py b/django/template/__init__.py
index 4cb4f21156..9811a5649d 100644
--- a/django/template/__init__.py
+++ b/django/template/__init__.py
@@ -99,6 +99,10 @@ libraries = {}
# global list of libraries to load by default for a new parser
builtins = []
+# True if TEMPLATE_STRING_IF_INVALID contains a format string (%s). None means
+# uninitialised.
+invalid_var_format_string = None
+
class TemplateSyntaxError(Exception):
def __str__(self):
try:
@@ -575,6 +579,11 @@ class FilterExpression(object):
obj = None
else:
if settings.TEMPLATE_STRING_IF_INVALID:
+ global invalid_var_format_string
+ if invalid_var_format_string is None:
+ invalid_var_format_string = '%s' in settings.TEMPLATE_STRING_IF_INVALID
+ if invalid_var_format_string:
+ return settings.TEMPLATE_STRING_IF_INVALID % self.var
return settings.TEMPLATE_STRING_IF_INVALID
else:
obj = settings.TEMPLATE_STRING_IF_INVALID