jinja2.parser.Parser

class jinja2.parser.Parser(environment, source, name=None, filename=None, state=None)[source]

This is the central parsing class Jinja2 uses. It’s passed to extensions and can be used to parse expressions or statements.

Methods

__init__(environment, source[, name, ...])
fail(msg[, lineno, exc]) Convenience method that raises exc with the message, passed line number or last line number as well as the current name and filename.
fail_eof([end_tokens, lineno]) Like fail_unknown_tag but for end of template situations.
fail_unknown_tag(name[, lineno]) Called if the parser encounters an unknown tag.
free_identifier([lineno]) Return a new free identifier as InternalName.
is_tuple_end([extra_end_rules]) Are we at the end of a tuple?
parse() Parse the whole template into a Template node.
parse_add()
parse_and()
parse_assign_target([with_tuple, name_only, ...]) Parse an assignment target.
parse_block()
parse_call(node)
parse_call_block()
parse_compare()
parse_concat()
parse_condexpr()
parse_dict()
parse_div()
parse_expression([with_condexpr]) Parse an expression.
parse_extends()
parse_filter(node[, start_inline])
parse_filter_block()
parse_filter_expr(node)
parse_floordiv()
parse_for() Parse a for loop.
parse_from()
parse_if() Parse an if construct.
parse_import()
parse_import_context(node, default)
parse_include()
parse_list()
parse_macro()
parse_mod()
parse_mul()
parse_not()
parse_or()
parse_postfix(node)
parse_pow()
parse_primary()
parse_print()
parse_set() Parse an assign statement.
parse_signature(node)
parse_statement() Parse a single statement.
parse_statements(end_tokens[, drop_needle]) Parse multiple statements into a list until one of the end tokens is reached.
parse_sub()
parse_subscribed()
parse_subscript(node)
parse_test(node)
parse_tuple([simplified, with_condexpr, ...]) Works like parse_expression but if multiple expressions are delimited by a comma a Tuple node is created.
parse_unary([with_filter])
subparse([end_tokens])