Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Aymeric Augustin authored December 09, 2011
10  django/template/base.py
@@ -250,15 +250,15 @@ def parse(self, parse_until=None):
250 250
                 var_node = self.create_variable_node(filter_expression)
251 251
                 self.extend_nodelist(nodelist, var_node, token)
252 252
             elif token.token_type == TOKEN_BLOCK:
253  
-                if token.contents in parse_until:
254  
-                    # put token back on token list so calling
255  
-                    # code knows why it terminated
256  
-                    self.prepend_token(token)
257  
-                    return nodelist
258 253
                 try:
259 254
                     command = token.contents.split()[0]
260 255
                 except IndexError:
261 256
                     self.empty_block_tag(token)
  257
+                if command in parse_until:
  258
+                    # put token back on token list so calling
  259
+                    # code knows why it terminated
  260
+                    self.prepend_token(token)
  261
+                    return nodelist
262 262
                 # execute callback function for this tag and append
263 263
                 # resulting node
264 264
                 self.enter_command(command, token)
10  django/template/loader_tags.py
@@ -189,8 +189,14 @@ def do_block(parser, token):
189 189
         parser.__loaded_blocks.append(block_name)
190 190
     except AttributeError: # parser.__loaded_blocks isn't a list yet
191 191
         parser.__loaded_blocks = [block_name]
192  
-    nodelist = parser.parse(('endblock', 'endblock %s' % block_name))
193  
-    parser.delete_first_token()
  192
+    nodelist = parser.parse(('endblock',))
  193
+
  194
+    # This check is kept for backwards-compatibility. See #3100.
  195
+    endblock = parser.next_token()
  196
+    acceptable_endblocks = ('endblock', 'endblock %s' % block_name)
  197
+    if endblock.contents not in acceptable_endblocks:
  198
+        parser.invalid_block_tag(endblock, 'endblock', acceptable_endblocks)
  199
+
194 200
     return BlockNode(block_name, nodelist)
195 201
 
196 202
 @register.tag('extends')

0 notes on commit 959f78b

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