Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #3100 -- Added support for arguments on intermediate tag tokens.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17186 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 959f78b3c6fa77dc7df9cd449634dda240e12c75 1 parent 718a5ba
@aaugustin aaugustin authored
Showing with 13 additions and 7 deletions.
  1. +5 −5 django/template/base.py
  2. +8 −2 django/template/loader_tags.py
View
10 django/template/base.py
@@ -250,15 +250,15 @@ def parse(self, parse_until=None):
var_node = self.create_variable_node(filter_expression)
self.extend_nodelist(nodelist, var_node, token)
elif token.token_type == TOKEN_BLOCK:
- if token.contents in parse_until:
- # put token back on token list so calling
- # code knows why it terminated
- self.prepend_token(token)
- return nodelist
try:
command = token.contents.split()[0]
except IndexError:
self.empty_block_tag(token)
+ if command in parse_until:
+ # put token back on token list so calling
+ # code knows why it terminated
+ self.prepend_token(token)
+ return nodelist
# execute callback function for this tag and append
# resulting node
self.enter_command(command, token)
View
10 django/template/loader_tags.py
@@ -189,8 +189,14 @@ def do_block(parser, token):
parser.__loaded_blocks.append(block_name)
except AttributeError: # parser.__loaded_blocks isn't a list yet
parser.__loaded_blocks = [block_name]
- nodelist = parser.parse(('endblock', 'endblock %s' % block_name))
- parser.delete_first_token()
+ nodelist = parser.parse(('endblock',))
+
+ # This check is kept for backwards-compatibility. See #3100.
+ endblock = parser.next_token()
+ acceptable_endblocks = ('endblock', 'endblock %s' % block_name)
+ if endblock.contents not in acceptable_endblocks:
+ parser.invalid_block_tag(endblock, 'endblock', acceptable_endblocks)
+
return BlockNode(block_name, nodelist)
@register.tag('extends')
Please sign in to comment.
Something went wrong with that request. Please try again.