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