MCPcopy
hub / github.com/pallets/jinja / parse

Method parse

src/jinja2/environment.py:599–616  ·  src/jinja2/environment.py::Environment.parse

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,
    )

Source from the content-addressed store, hash-verified

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]

Callers 2

babel_extractFunction · 0.95
_parseMethod · 0.45

Calls 2

_parseMethod · 0.95
handle_exceptionMethod · 0.95

Tested by

no test coverage detected