| 61 | | def __init__(self, loopvar, sequence, reversed, nodelist_loop): |
|---|
| 62 | | self.loopvar, self.sequence = loopvar, sequence |
|---|
| | 61 | def __init__(self, loopvars, sequence, reversed, nodelist_loop): |
|---|
| | 62 | self.loopvars, self.sequence = loopvars, sequence |
|---|
| 526 | | if len(bits) == 5 and bits[4] != 'reversed': |
|---|
| 527 | | raise TemplateSyntaxError, "'for' statements with five words should end in 'reversed': %s" % token.contents |
|---|
| 528 | | if len(bits) not in (4, 5): |
|---|
| 529 | | raise TemplateSyntaxError, "'for' statements should have either four or five words: %s" % token.contents |
|---|
| 530 | | if bits[2] != 'in': |
|---|
| 531 | | raise TemplateSyntaxError, "'for' statement must contain 'in' as the second word: %s" % token.contents |
|---|
| 532 | | loopvar = bits[1] |
|---|
| 533 | | sequence = parser.compile_filter(bits[3]) |
|---|
| 534 | | reversed = (len(bits) == 5) |
|---|
| | 527 | #if len(bits) == 5 and bits[4] != 'reversed': |
|---|
| | 528 | # raise TemplateSyntaxError, "'for' statements with five words should end in 'reversed': %s" % token.contents |
|---|
| | 529 | if len(bits) < 4: |
|---|
| | 530 | raise TemplateSyntaxError, "'for' statements should have at leat four words: %s" % token.contents |
|---|
| | 531 | |
|---|
| | 532 | try: |
|---|
| | 533 | in_index = bits.index('in') |
|---|
| | 534 | except ValueError: |
|---|
| | 535 | raise TemplateSyntaxError, "'for' statement must contain 'in': %s" % token.contents |
|---|
| | 536 | |
|---|
| | 537 | loopvars = [] |
|---|
| | 538 | for bit in bits[1:in_index]: |
|---|
| | 539 | if bit.find(',') == -1: |
|---|
| | 540 | loopvars.append( bit ) |
|---|
| | 541 | elif len(bit) > 1: |
|---|
| | 542 | loopvars.extend( b for b in bit.split(',') if b ) |
|---|
| | 543 | |
|---|
| | 544 | sequence = parser.compile_filter(bits[in_index+1]) |
|---|
| | 545 | reversed = ( bits[-1] == 'reversed' ) |
|---|