summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorChris Beaven <smileychris@gmail.com>2012-06-19 10:49:30 +1200
committerChris Beaven <smileychris@gmail.com>2012-06-19 10:49:33 +1200
commitc57ba673312cb5774d544353044e2182b6223040 (patch)
tree366a3cf580fce4437191d2594af9ab6b9d1f7bef /django
parentffa6d95f65363b7f4f9047ab11561880be29049a (diff)
Fixed #14502 again -- saner verbatim closing token
Previously, the closing token for the verbatim tag was specified as the first argument of the opening token. As pointed out by Jannis, this is a rather major departure from the core tag standard. The new method reflects how you can give a specific closing name to {% block %} tags.
Diffstat (limited to 'django')
-rw-r--r--django/template/base.py9
-rw-r--r--django/template/defaulttags.py14
2 files changed, 7 insertions, 16 deletions
diff --git a/django/template/base.py b/django/template/base.py
index 5a91bfda99..89bc90971f 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -216,13 +216,8 @@ class Lexer(object):
if token_string.startswith(VARIABLE_TAG_START):
token = Token(TOKEN_VAR, token_string[2:-2].strip())
elif token_string.startswith(BLOCK_TAG_START):
- if block_content.startswith('verbatim'):
- bits = block_content.split(' ', 1)
- if bits[0] == 'verbatim':
- if len(bits) > 1:
- self.verbatim = bits[1]
- else:
- self.verbatim = 'endverbatim'
+ if block_content[:9] in ('verbatim', 'verbatim '):
+ self.verbatim = 'end%s' % block_content
token = Token(TOKEN_BLOCK, block_content)
elif token_string.startswith(COMMENT_TAG_START):
content = ''
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 0de5d9e3db..83b72e120b 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -1291,18 +1291,14 @@ def verbatim(parser, token):
{% don't process this %}
{% endverbatim %}
- You can also specify an alternate closing tag::
+ You can also designate a specific closing tag block (allowing the
+ unrendered use of ``{% endverbatim %}``)::
- {% verbatim -- %}
+ {% verbatim myblock %}
...
- {% -- %}
+ {% endverbatim myblock %}
"""
- bits = token.contents.split(' ', 1)
- if len(bits) > 1:
- closing_tag = bits[1]
- else:
- closing_tag = 'endverbatim'
- nodelist = parser.parse((closing_tag,))
+ nodelist = parser.parse(('endverbatim',))
parser.delete_first_token()
return VerbatimNode(nodelist.render(Context()))