module documentation

AST nodes generated by the parser for the compiler. Also provides some node tree helper functions used by the parser and compiler in order to normalize nodes.

Class Add Add the left to the right node.
Class And Short circuited AND.
Class Assign Assigns an expression to a target.
Class AssignBlock Assigns a block to a target.
Class BinExpr Baseclass for all binary expressions.
Class Block A node that represents a block.
Class Break Break a loop.
Class Call Calls an expression. `args` is a list of arguments, `kwargs` a list of keyword arguments (list of :class:`Keyword` nodes), and `dyn_args` and `dyn_kwargs` has to be either `None` or a node that is used as node for dynamic positional (``*args``) or keyword (``**kwargs``) arguments.
Class CallBlock Like a macro without a name but a call instead. `call` is called with the unnamed macro as `caller` argument this node holds.
Class Compare Compares an expression with some other expressions. `ops` must be a list of :class:`Operand`\s.
Class Concat Concatenates the list of expressions provided after converting them to strings.
Class CondExpr A conditional expression (inline if expression). (``{{ foo if bar else baz }}``)
Class Const All constant values. The parser will return this node for simple constants such as ``42`` or ``"foo"`` but it can be used to store more complex values such as lists too. Only constants with a safe representation (objects where ``eval(repr(x)) == x`` is true).
Class ContextReference Returns the current template context. It can be used like a :class:`Name` node, with a ``'load'`` ctx and will return the current :class:`~jinja2.runtime.Context` object.
Class Continue Continue a loop.
Class DerivedContextReference Return the current template context including locals. Behaves exactly like :class:`ContextReference`, but includes local variables, such as from a ``for`` loop.
Class Dict Any dict literal such as ``{1: 2, 3: 4}``. The items must be a list of :class:`Pair` nodes.
Class Div Divides the left by the right node.
Class EnvironmentAttribute Loads an attribute from the environment object. This is useful for extensions that want to call a callback stored on the environment.
Class EvalContext Holds evaluation time information. Custom attributes can be attached to it in extensions.
Class EvalContextModifier Modifies the eval context. For each option that should be modified, a :class:`Keyword` has to be added to the :attr:`options` list.
Class Expr Baseclass for all expressions.
Class ExprStmt A statement that evaluates an expression and discards the result.
Class Extends Represents an extends statement.
Class ExtensionAttribute Returns the attribute of an extension bound to the environment. The identifier is the identifier of the :class:`Extension`.
Class Filter Apply a filter to an expression. ``name`` is the name of the filter, the other fields are the same as :class:`Call`.
Class FilterBlock Node for filter sections.
Class FloorDiv Divides the left by the right node and converts the result into an integer by truncating.
Class For The for loop. `target` is the target for the iteration (usually a :class:`Name` or :class:`Tuple`), `iter` the iterable. `body` is a list of nodes that are used as loop-body, and `else_` a list of nodes for the `else` block...
Class FromImport A node that represents the from import tag. It's important to not pass unsafe names to the name attribute. The compiler translates the attribute lookups directly into getattr calls and does *not* use the subscript callback of the interface...
Class Getattr Get an attribute or item from an expression that is a ascii-only bytestring and prefer the attribute.
Class Getitem Get an attribute or item from an expression and prefer the item.
Class Helper Nodes that exist in a specific context only.
Class If If `test` is true, `body` is rendered, else `else_`.
Class Import A node that represents the import tag.
Class ImportedName If created with an import name the import name is returned on node access. For example ``ImportedName('cgi.escape')`` returns the `escape` function from the cgi module on evaluation. Imports are optimized by the compiler so there is no need to assign them to local variables.
Class Impossible Raised if the node could not perform a requested action.
Class Include A node that represents the include tag.
Class InternalName An internal name in the compiler. You cannot create these nodes yourself but the parser provides a :meth:`~jinja2.parser.Parser.free_identifier` method that creates a new identifier for you. This identifier is not available from the template and is not treated specially by the compiler.
Class Keyword A key, value pair for keyword arguments where key is a string.
Class List Any list literal such as ``[1, 2, 3]``
Class Literal Baseclass for literals.
Class Macro A macro definition. `name` is the name of the macro, `args` a list of arguments and `defaults` a list of defaults if there are any. `body` is a list of nodes for the macro body.
Class MarkSafe Mark the wrapped expression as safe (wrap it as `Markup`).
Class MarkSafeIfAutoescape Mark the wrapped expression as safe (wrap it as `Markup`) but only if autoescaping is active.
Class Mod Left modulo right.
Class Mul Multiplies the left with the right node.
Class Name Looks up a name or stores a value in a name. The `ctx` of the node can be one of the following values:
Class Neg Make the expression negative.
Class Node Baseclass for all Jinja nodes. There are a number of nodes available of different types. There are four major types:
Class NodeType A metaclass for nodes that handles the field and attribute inheritance. fields and attributes from the parent class are automatically forwarded to the child.
Class Not Negate the expression.
Class NSRef Reference to a namespace value assignment
Class Operand Holds an operator and an expression.
Class Or Short circuited OR.
Class Output A node that holds multiple expressions which are then printed out. This is used both for the `print` statement and the regular template data.
Class OverlayScope An overlay scope for extensions. This is a largely unoptimized scope that however can be used to introduce completely arbitrary variables into a sub scope from a dictionary or dictionary like object. ...
Class Pair A key, value pair for dicts.
Class Pos Make the expression positive (noop for most expressions)
Class Pow Left to the power of right.
Class Scope An artificial scope.
Class ScopedEvalContextModifier Modifies the eval context and reverts it later. Works exactly like :class:`EvalContextModifier` but will only modify the :class:`~jinja2.nodes.EvalContext` for nodes in the :attr:`body`.
Class Slice Represents a slice object. This must only be used as argument for :class:`Subscript`.
Class Stmt Base node for all statements.
Class Sub Subtract the right from the left node.
Class Template Node that represents a template. This must be the outermost node that is passed to the compiler.
Class TemplateData A constant template string.
Class Test Apply a test to an expression. ``name`` is the name of the test, the other field are the same as :class:`Call`.
Class Tuple For loop unpacking and some other things like multiple arguments for subscripts. Like for :class:`Name` `ctx` specifies if the tuple is used for loading the names or storing.
Class UnaryExpr Baseclass for all unary expressions.
Class With Specific node for with statements. In older versions of Jinja the with statement was implemented on the base of the `Scope` node instead.
Function args_as_const Undocumented
Function get_eval_context Undocumented
Class _FilterTestCommon Undocumented
Function _failing_new Undocumented
Variable _binop_to_func Undocumented
Variable _cmpop_to_func Undocumented
Variable _NodeBound Undocumented
Variable _uaop_to_func Undocumented
def args_as_const(node, eval_ctx): (source)

Undocumented

Parameters
node:t.Union[_FilterTestCommon, Call]Undocumented
eval_ctx:t.Optional[EvalContext]Undocumented
Returns
t.Tuple[t.List[t.Any], t.Dict[t.Any, t.Any]]Undocumented
def get_eval_context(node, ctx): (source)

Undocumented

Parameters
node:NodeUndocumented
ctx:t.Optional[EvalContext]Undocumented
Returns
EvalContextUndocumented
def _failing_new(*args, **kwargs): (source)

Undocumented

Parameters
*args:t.AnyUndocumented
**kwargs:t.AnyUndocumented
Returns
te.NoReturnUndocumented
_binop_to_func: t.Dict[str, t.Callable[[t.Any, t.Any], t.Any]] = (source)

Undocumented

_cmpop_to_func: t.Dict[str, t.Callable[[t.Any, t.Any], t.Any]] = (source)

Undocumented

_NodeBound = (source)

Undocumented

_uaop_to_func: t.Dict[str, t.Callable[[t.Any], t.Any]] = (source)

Undocumented