render_context
Module handling rendering context variables (eg. for !expr and !j2)
context_providers: List[Union[Callable, List[ContextVar]]] = [base_provider, underscore_context_provider]
module-attribute
Provides a list of context providers. See :func:get_render_context() for details
ContextVar
Bases: NamedTuple
A specification for a context variable used for rendering dynamic values.
Either if function
is specified, we'll call the function to get the actual
value.
Source code in gamma/config/render_context.py
cacheable: bool = False
class-attribute
If True, will cache the function result, otherwise will call on each render.
function: Optional[Callable[..., Any]] = None
class-attribute
Function to call to resolve the variable
name: str
class-attribute
The name of the variable
value: Any = None
class-attribute
The value of the variable
base_provider(**kwargs)
Defaults to context
env
-> os.environc
-> the global RootConfig
Source code in gamma/config/render_context.py
get_render_context(**kwargs)
Return the render context by calling each function in context_provider
.
A context provider must be a function with the signature
(**kwargs) -> List[ContextVar]
or simply a list of ContextVar
objects
The provided **kwargs
are the same available in the render_node
function
Source code in gamma/config/render_context.py
underscore_context_provider(*, config=None, **kwargs)
Look in parent config nodes and add all entries under the _context
key