1
0
mirror of https://github.com/django/django.git synced 2024-12-25 18:46:22 +00:00

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
This commit is contained in:
Aymeric Augustin 2011-12-09 22:10:52 +00:00
parent 718a5ba1a1
commit 959f78b3c6
2 changed files with 13 additions and 7 deletions

View File

@ -250,15 +250,15 @@ class Parser(object):
var_node = self.create_variable_node(filter_expression) var_node = self.create_variable_node(filter_expression)
self.extend_nodelist(nodelist, var_node, token) self.extend_nodelist(nodelist, var_node, token)
elif token.token_type == TOKEN_BLOCK: 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: try:
command = token.contents.split()[0] command = token.contents.split()[0]
except IndexError: except IndexError:
self.empty_block_tag(token) 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 # execute callback function for this tag and append
# resulting node # resulting node
self.enter_command(command, token) self.enter_command(command, token)

View File

@ -189,8 +189,14 @@ def do_block(parser, token):
parser.__loaded_blocks.append(block_name) parser.__loaded_blocks.append(block_name)
except AttributeError: # parser.__loaded_blocks isn't a list yet except AttributeError: # parser.__loaded_blocks isn't a list yet
parser.__loaded_blocks = [block_name] parser.__loaded_blocks = [block_name]
nodelist = parser.parse(('endblock', 'endblock %s' % block_name)) nodelist = parser.parse(('endblock',))
parser.delete_first_token()
# 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) return BlockNode(block_name, nodelist)
@register.tag('extends') @register.tag('extends')