diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-05-08 03:36:16 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-05-08 03:36:16 +0000 |
| commit | faa31732caa17d942b05fd4e25c49bb0589ce76f (patch) | |
| tree | ba6261d981bb1e583938838696da8e0e23ac3532 /django | |
| parent | 77ec8ae811f0f9d6a55c570ee7c02c52e6e7bc8d (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__.py | 9 |
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 |
