(tokens, name, context)
| 911 | |
| 912 | |
| 913 | def parse_one_cond(tokens, name, context): |
| 914 | (first, pos), tokens = tokens[0], tokens[1:] |
| 915 | content = [] |
| 916 | if first.endswith(':'): |
| 917 | first = first[:-1] |
| 918 | if first.startswith('if '): |
| 919 | part = ('if', pos, first[3:].lstrip(), content) |
| 920 | elif first.startswith('elif '): |
| 921 | part = ('elif', pos, first[5:].lstrip(), content) |
| 922 | elif first == 'else': |
| 923 | part = ('else', pos, None, content) |
| 924 | else: |
| 925 | assert 0, "Unexpected token %r at %s" % (first, pos) |
| 926 | while 1: |
| 927 | if not tokens: |
| 928 | raise TemplateError( |
| 929 | 'No {{endif}}', |
| 930 | position=pos, name=name) |
| 931 | if (isinstance(tokens[0], tuple) and ( |
| 932 | tokens[0][0] == 'endif' or tokens[0][0].startswith( |
| 933 | 'elif ') or tokens[0][0] == 'else')): |
| 934 | return part, tokens |
| 935 | next_chunk, tokens = parse_expr(tokens, name, context) |
| 936 | content.append(next_chunk) |
| 937 | |
| 938 | |
| 939 | def parse_for(tokens, name, context): |
no test coverage detected