Parse the sourcecode and return the abstract syntax tree. This tree of nodes is used by the compiler to convert the template into executable source- or bytecode. This is useful for debugging or to extract information from templates. If you are :ref:`developing Jinj
(
self,
source: str,
name: t.Optional[str] = None,
filename: t.Optional[str] = None,
)
| 597 | |
| 598 | @internalcode |
| 599 | def parse( |
| 600 | self, |
| 601 | source: str, |
| 602 | name: t.Optional[str] = None, |
| 603 | filename: t.Optional[str] = None, |
| 604 | ) -> nodes.Template: |
| 605 | class="st">"""Parse the sourcecode and return the abstract syntax tree. This |
| 606 | tree of nodes is used by the compiler to convert the template into |
| 607 | executable source- or bytecode. This is useful for debugging or to |
| 608 | extract information from templates. |
| 609 | |
| 610 | If you are :ref:`developing Jinja extensions <writing-extensions>` |
| 611 | this gives you a good overview of the node tree generated. |
| 612 | class="st">""" |
| 613 | try: |
| 614 | return self._parse(source, name, filename) |
| 615 | except TemplateSyntaxError: |
| 616 | self.handle_exception(source=source) |
| 617 | |
| 618 | def _parse( |
| 619 | self, source: str, name: t.Optional[str], filename: t.Optional[str] |
no test coverage detected