jinja2.nodes.ContextReference

class jinja2.nodes.ContextReference(*fields, **attributes)[source]

Returns the current template context. It can be used like a Name node, with a 'load' ctx and will return the current Context object.

Here an example that assigns the current template name to a variable named foo:

Assign(Name('foo', ctx='store'),
       Getattr(ContextReference(), 'name'))

Methods

__init__(*fields, **attributes)
as_const([eval_ctx]) Return the value of the expression as constant or raise Impossible if this was not possible.
can_assign() Check if it’s possible to assign something to this node.
find(node_type) Find the first node of a given type.
find_all(node_type) Find all the nodes of a given type.
iter_child_nodes([exclude, only]) Iterates over all direct child nodes of the node.
iter_fields([exclude, only]) This method iterates over all fields that are defined and yields (key, value) tuples.
set_ctx(ctx) Reset the context of a node and all child nodes.
set_environment(environment) Set the environment for all nodes.
set_lineno(lineno[, override]) Set the line numbers of the node and children.