Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
jinja2.runtime.Context Class Reference

Public Member Functions

 __init__ (self, "Environment" environment, t.Dict[str, t.Any] parent, t.Optional[str] name, t.Dict[str, t.Callable[["Context"], t.Iterator[str]]] blocks, t.Optional[t.MutableMapping[str, t.Any]] globals=None)
 
t.Union["BlockReference", "Undefined"] super (self, str name, t.Callable[["Context"], t.Iterator[str]] current)
 
t.Any get (self, str key, t.Any default=None)
 
t.Union[t.Any, "Undefined"] resolve (self, str key)
 
t.Any resolve_or_missing (self, str key)
 
t.Dict[str, t.Any] get_exported (self)
 
t.Dict[str, t.Any] get_all (self)
 
t.Union[t.Any, "Undefined"] call (__self, t.Callable[..., t.Any] __obj, *t.Any args, **t.Any kwargs)
 
"Context" derived (self, t.Optional[t.Dict[str, t.Any]] locals=None)
 
bool __contains__ (self, str name)
 
t.Any __getitem__ (self, str key)
 
str __repr__ (self)
 

Public Attributes

 parent
 
 eval_ctx
 
 name
 
 globals_keys
 
 blocks
 
 vars
 
 environment
 

Static Public Attributes

 keys = _dict_method_all(dict.keys)
 
 values = _dict_method_all(dict.values)
 
 items = _dict_method_all(dict.items)
 

Detailed Description

The template context holds the variables of a template.  It stores the
values passed to the template and also the names the template exports.
Creating instances is neither supported nor useful as it's created
automatically at various stages of the template evaluation and should not
be created by hand.

The context is immutable.  Modifications on :attr:`parent` **must not**
happen and modifications on :attr:`vars` are allowed from generated
template code only.  Template filters and global functions marked as
:func:`pass_context` get the active context passed as first argument
and are allowed to access the context read-only.

The template context supports read only dict operations (`get`,
`keys`, `values`, `items`, `iterkeys`, `itervalues`, `iteritems`,
`__getitem__`, `__contains__`).  Additionally there is a :meth:`resolve`
method that doesn't fail with a `KeyError` but returns an
:class:`Undefined` object for missing variables.

Member Function Documentation

◆ __getitem__()

t.Any jinja2.runtime.Context.__getitem__ (   self,
str  key 
)
Look up a variable by name with ``[]`` syntax, or raise a
``KeyError`` if the key is not found.

◆ call()

t.Union[t.Any, "Undefined"] jinja2.runtime.Context.call (   __self,
t.Callable[..., t.Any]  __obj,
*t.Any  args,
**t.Any  kwargs 
)
Call the callable with the arguments and keyword arguments
provided but inject the active context or environment as first
argument if the callable has :func:`pass_context` or
:func:`pass_environment`.

◆ derived()

"Context" jinja2.runtime.Context.derived (   self,
t.Optional[t.Dict[str, t.Any]]   locals = None 
)
Internal helper function to create a derived context.  This is
used in situations where the system needs a new context in the same
template that is independent.

◆ get()

t.Any jinja2.runtime.Context.get (   self,
str  key,
t.Any   default = None 
)
Look up a variable by name, or return a default if the key is
not found.

:param key: The variable name to look up.
:param default: The value to return if the key is not found.

◆ get_all()

t.Dict[str, t.Any] jinja2.runtime.Context.get_all (   self)
Return the complete context as dict including the exported
variables.  For optimizations reasons this might not return an
actual copy so be careful with using it.

◆ get_exported()

t.Dict[str, t.Any] jinja2.runtime.Context.get_exported (   self)
Get a new dict with the exported variables.

◆ resolve()

t.Union[t.Any, "Undefined"] jinja2.runtime.Context.resolve (   self,
str  key 
)
Look up a variable by name, or return an :class:`Undefined`
object if the key is not found.

If you need to add custom behavior, override
:meth:`resolve_or_missing`, not this method. The various lookup
functions use that method, not this one.

:param key: The variable name to look up.

◆ resolve_or_missing()

t.Any jinja2.runtime.Context.resolve_or_missing (   self,
str  key 
)
Look up a variable by name, or return a ``missing`` sentinel
if the key is not found.

Override this method to add custom lookup behavior.
:meth:`resolve`, :meth:`get`, and :meth:`__getitem__` use this
method. Don't call this method directly.

:param key: The variable name to look up.

◆ super()

t.Union["BlockReference", "Undefined"] jinja2.runtime.Context.super (   self,
str  name,
t.Callable[["Context"], t.Iterator[str]]   current 
)
Render a parent block.

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