OpenQuizz
Une application de gestion des contenus pédagogiques
ContextReference Class Reference
Inheritance diagram for ContextReference:
Collaboration diagram for ContextReference:

Additional Inherited Members

- Public Member Functions inherited from Expr
def as_const (self, eval_ctx=None)
 
def can_assign (self)
 
- Public Member Functions inherited from Node
def __init__ (self, *fields, **attributes)
 
def iter_fields (self, exclude=None, only=None)
 
def iter_child_nodes (self, exclude=None, only=None)
 
def find (self, node_type)
 
def find_all (self, node_type)
 
def set_ctx (self, ctx)
 
def set_lineno (self, lineno, override=False)
 
def set_environment (self, environment)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def __repr__ (self)
 
def dump (self)
 
- Public Member Functions inherited from NodeType
def __new__ (mcs, name, bases, d)
 
- Static Public Attributes inherited from Expr
 abstract
 
- Static Public Attributes inherited from Node
 fields
 
 attributes
 
 abstract
 

Detailed Description

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.

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

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

This is basically equivalent to using the
:func:`~jinja2.contextfunction` decorator when using the
high-level API, which causes a reference to the context to be passed
as the first argument to a function.

The documentation for this class was generated from the following file: