Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #2181 -- allow '{' and '}' to be escaped via {% templatetag ...…

… %}.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3138 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 75a8a32f8629b47135890ac6ecda061a616d1cfc 1 parent 4540a85
@malcolmt malcolmt authored
View
2  django/template/__init__.py
@@ -75,6 +75,8 @@
BLOCK_TAG_END = '%}'
VARIABLE_TAG_START = '{{'
VARIABLE_TAG_END = '}}'
+SINGLE_BRACE_START = '{'
+SINGLE_BRACE_END = '}'
ALLOWED_VARIABLE_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.'
View
9 django/template/defaulttags.py
@@ -1,7 +1,7 @@
"Default tags used by the template system, available to all templates."
from django.template import Node, NodeList, Template, Context, resolve_variable
-from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END
+from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END
from django.template import get_library, Library, InvalidTemplateLibrary
from django.conf import settings
import sys
@@ -275,7 +275,10 @@ class TemplateTagNode(Node):
mapping = {'openblock': BLOCK_TAG_START,
'closeblock': BLOCK_TAG_END,
'openvariable': VARIABLE_TAG_START,
- 'closevariable': VARIABLE_TAG_END}
+ 'closevariable': VARIABLE_TAG_END,
+ 'openbrace': SINGLE_BRACE_START,
+ 'closebrace': SINGLE_BRACE_END,
+ }
def __init__(self, tagtype):
self.tagtype = tagtype
@@ -809,6 +812,8 @@ def templatetag(parser, token):
``closeblock`` ``%}``
``openvariable`` ``{{``
``closevariable`` ``}}``
+ ``openbrace`` ``{``
+ ``closebrace`` ``}``
================== =======
"""
bits = token.contents.split()
View
2  docs/templates.txt
@@ -766,6 +766,8 @@ The argument tells which template bit to output:
``closeblock`` ``%}``
``openvariable`` ``{{``
``closevariable`` ``}}``
+ ``openbrace`` ``{``
+ ``closebrace`` ``}``
================== =======
widthratio
View
4 tests/othertests/templates.py
@@ -499,6 +499,10 @@ def method(self):
'templatetag04': ('{% templatetag closevariable %}', {}, '}}'),
'templatetag05': ('{% templatetag %}', {}, template.TemplateSyntaxError),
'templatetag06': ('{% templatetag foo %}', {}, template.TemplateSyntaxError),
+ 'templatetag07': ('{% templatetag openbrace %}', {}, '{'),
+ 'templatetag08': ('{% templatetag closebrace %}', {}, '}'),
+ 'templatetag09': ('{% templatetag openbrace %}{% templatetag openbrace %}', {}, '{{'),
+ 'templatetag10': ('{% templatetag closebrace %}{% templatetag closebrace %}', {}, '}}'),
### WIDTHRATIO TAG ########################################################
'widthratio01': ('{% widthratio a b 0 %}', {'a':50,'b':100}, '0'),

0 comments on commit 75a8a32

Please sign in to comment.
Something went wrong with that request. Please try again.