Ticket #3100: 3100-alternate.diff

File 3100-alternate.diff, 1.3 KB (added by Chris Beaven, 13 years ago)

An alternative to adding a parse_until_args_allowed argument

  • django/template/base.py

    diff --git a/django/template/base.py b/django/template/base.py
    index eacc29c..a315c05 100644
    a b class Parser(object):  
    222222                var_node = self.create_variable_node(filter_expression)
    223223                self.extend_nodelist(nodelist, var_node,token)
    224224            elif token.token_type == TOKEN_BLOCK:
    225                 if token.contents in parse_until:
    226                     # put token back on token list so calling code knows why it terminated
    227                     self.prepend_token(token)
    228                     return nodelist
     225                for value in parse_until:
     226                    # A parse_until value which ends in a ' ' will match any
     227                    # token starting with that value, otherwise an exact match
     228                    # is required.
     229                    if (value == token.contents or value.endswith(' ')
     230                            and token.contents.startswith(value)):
     231                        # Put token back on token list so calling code knows
     232                        # why it terminated.
     233                        self.prepend_token(token)
     234                        return nodelist
    229235                try:
    230236                    command = token.contents.split()[0]
    231237                except IndexError:
Back to Top