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, name=None, filename=None)
| 478 | |
| 479 | @internalcode |
| 480 | def parse(self, source, name=None, filename=None): |
| 481 | """Parse the sourcecode and return the abstract syntax tree. This |
| 482 | tree of nodes is used by the compiler to convert the template into |
| 483 | executable source- or bytecode. This is useful for debugging or to |
| 484 | extract information from templates. |
| 485 | |
| 486 | If you are :ref:`developing Jinja2 extensions <writing-extensions>` |
| 487 | this gives you a good overview of the node tree generated. |
| 488 | """ |
| 489 | try: |
| 490 | return self._parse(source, name, filename) |
| 491 | except TemplateSyntaxError: |
| 492 | exc_info = sys.exc_info() |
| 493 | self.handle_exception(exc_info, source_hint=source) |
| 494 | |
| 495 | def _parse(self, source, name, filename): |
| 496 | """Internal parsing function used by `parse` and `compile`.""" |
no test coverage detected