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 the left to the right node. |
Class |
|
Short circuited AND. |
Class |
|
Assigns an expression to a target. |
Class |
|
Assigns a block to a target. |
Class |
|
Baseclass for all binary expressions. |
Class |
|
A node that represents a block. |
Class |
|
Break a loop. |
Class |
|
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 |
|
Like a macro without a name but a call instead. `call` is called with the unnamed macro as `caller` argument this node holds. |
Class |
|
Compares an expression with some other expressions. `ops` must be a list of :class:`Operand`\s. |
Class |
|
Concatenates the list of expressions provided after converting them to strings. |
Class |
|
A conditional expression (inline if expression). (``{{ foo if bar else baz }}``) |
Class |
|
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 |
|
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 a loop. |
Class |
|
Return the current template context including locals. Behaves exactly like :class:`ContextReference`, but includes local variables, such as from a ``for`` loop. |
Class |
|
Any dict literal such as ``{1: 2, 3: 4}``. The items must be a list of :class:`Pair` nodes. |
Class |
|
Divides the left by the right node. |
Class |
|
Loads an attribute from the environment object. This is useful for extensions that want to call a callback stored on the environment. |
Class |
|
Holds evaluation time information. Custom attributes can be attached to it in extensions. |
Class |
|
Modifies the eval context. For each option that should be modified, a :class:`Keyword` has to be added to the :attr:`options` list. |
Class |
|
Baseclass for all expressions. |
Class |
|
A statement that evaluates an expression and discards the result. |
Class |
|
Represents an extends statement. |
Class |
|
Returns the attribute of an extension bound to the environment. The identifier is the identifier of the :class:`Extension`. |
Class |
|
Apply a filter to an expression. ``name`` is the name of the filter, the other fields are the same as :class:`Call`. |
Class |
|
Node for filter sections. |
Class |
|
Divides the left by the right node and converts the result into an integer by truncating. |
Class |
|
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 |
|
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 |
|
Get an attribute or item from an expression that is a ascii-only bytestring and prefer the attribute. |
Class |
|
Get an attribute or item from an expression and prefer the item. |
Class |
|
Nodes that exist in a specific context only. |
Class |
|
If `test` is true, `body` is rendered, else `else_`. |
Class |
|
A node that represents the import tag. |
Class |
|
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 |
|
Raised if the node could not perform a requested action. |
Class |
|
A node that represents the include tag. |
Class |
|
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 |
|
A key, value pair for keyword arguments where key is a string. |
Class |
|
Any list literal such as ``[1, 2, 3]`` |
Class |
|
Baseclass for literals. |
Class |
|
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 |
|
Mark the wrapped expression as safe (wrap it as `Markup`). |
Class |
|
Mark the wrapped expression as safe (wrap it as `Markup`) but only if autoescaping is active. |
Class |
|
Left modulo right. |
Class |
|
Multiplies the left with the right node. |
Class |
|
Looks up a name or stores a value in a name. The `ctx` of the node can be one of the following values: |
Class |
|
Make the expression negative. |
Class |
|
Baseclass for all Jinja nodes. There are a number of nodes available of different types. There are four major types: |
Class |
|
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 |
|
Negate the expression. |
Class |
|
Reference to a namespace value assignment |
Class |
|
Holds an operator and an expression. |
Class |
|
Short circuited OR. |
Class |
|
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 |
|
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 |
|
A key, value pair for dicts. |
Class |
|
Make the expression positive (noop for most expressions) |
Class |
|
Left to the power of right. |
Class |
|
An artificial scope. |
Class |
|
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 |
|
Represents a slice object. This must only be used as argument for :class:`Subscript`. |
Class |
|
Base node for all statements. |
Class |
|
Subtract the right from the left node. |
Class |
|
Node that represents a template. This must be the outermost node that is passed to the compiler. |
Class |
|
A constant template string. |
Class |
|
Apply a test to an expression. ``name`` is the name of the test, the other field are the same as :class:`Call`. |
Class |
|
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 |
|
Baseclass for all unary expressions. |
Class |
|
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 |
Undocumented |
Function | get |
Undocumented |
Class | _ |
Undocumented |
Function | _failing |
Undocumented |
Variable | _binop |
Undocumented |
Variable | _cmpop |
Undocumented |
Variable | _ |
Undocumented |
Variable | _uaop |
Undocumented |
Undocumented
Parameters | |
node:t.Union[ | Undocumented |
evalt.Optional[ | Undocumented |
Returns | |
t.Tuple[ | Undocumented |
Undocumented
Parameters | |
node:Node | Undocumented |
ctx:t.Optional[ | Undocumented |
Returns | |
EvalContext | Undocumented |