Parse a single statement.
(self)
| 165 | return rv |
| 166 | |
| 167 | def parse_statement(self) -> t.Union[nodes.Node, t.List[nodes.Node]]: |
| 168 | """Parse a single statement.""" |
| 169 | token = self.stream.current |
| 170 | if token.type != "name": |
| 171 | self.fail("tag name expected", token.lineno) |
| 172 | self._tag_stack.append(token.value) |
| 173 | pop_tag = True |
| 174 | try: |
| 175 | if token.value in _statement_keywords: |
| 176 | f = getattr(self, f"parse_{self.stream.current.value}") |
| 177 | return f() # type: ignore |
| 178 | if token.value == "call": |
| 179 | return self.parse_call_block() |
| 180 | if token.value == "filter": |
| 181 | return self.parse_filter_block() |
| 182 | ext = self.extensions.get(token.value) |
| 183 | if ext is not None: |
| 184 | return ext(self) |
| 185 | |
| 186 | # did not work out, remove the token we pushed by accident |
| 187 | # from the stack so that the unknown tag fail function can |
| 188 | # produce a proper error message. |
| 189 | self._tag_stack.pop() |
| 190 | pop_tag = False |
| 191 | self.fail_unknown_tag(token.value, token.lineno) |
| 192 | finally: |
| 193 | if pop_tag: |
| 194 | self._tag_stack.pop() |
| 195 | |
| 196 | def parse_statements( |
| 197 | self, end_tokens: t.Tuple[str, ...], drop_needle: bool = False |
no test coverage detected