Parse a single statement.
(self)
| 119 | return rv |
| 120 | |
| 121 | def parse_statement(self): |
| 122 | """Parse a single statement.""" |
| 123 | token = self.stream.current |
| 124 | if token.type != 'name': |
| 125 | self.fail('tag name expected', token.lineno) |
| 126 | self._tag_stack.append(token.value) |
| 127 | pop_tag = True |
| 128 | try: |
| 129 | if token.value in _statement_keywords: |
| 130 | return getattr(self, 'parse_' + self.stream.current.value)() |
| 131 | if token.value == 'call': |
| 132 | return self.parse_call_block() |
| 133 | if token.value == 'filter': |
| 134 | return self.parse_filter_block() |
| 135 | ext = self.extensions.get(token.value) |
| 136 | if ext is not None: |
| 137 | return ext(self) |
| 138 | |
| 139 | # did not work out, remove the token we pushed by accident |
| 140 | # from the stack so that the unknown tag fail function can |
| 141 | # produce a proper error message. |
| 142 | self._tag_stack.pop() |
| 143 | pop_tag = False |
| 144 | self.fail_unknown_tag(token.value, token.lineno) |
| 145 | finally: |
| 146 | if pop_tag: |
| 147 | self._tag_stack.pop() |
| 148 | |
| 149 | def parse_statements(self, end_tokens, drop_needle=False): |
| 150 | """Parse multiple statements into a list until one of the end tokens |
no test coverage detected