Render context
liquid2.RenderContext
Template render state.
copy
copy(
token: TokenT,
*,
namespace: Mapping[str, object],
template: Template | None = None,
disabled_tags: set[str] | None = None,
carry_loop_iterations: bool = False,
block_scope: bool = False
) -> RenderContext
Return a copy of this render context with a new scope.
cycle
Return the index of the next item in the named cycle.
extend
extend(
namespace: Mapping[str, object],
template: Template | None = None,
) -> Iterator[RenderContext]
Extend this context with the given read-only namespace.
filter
Return the filter callable for name.
get
Resolve the variable path in the current namespace.
get_async
async
Asynchronously resolve the variable path in the current namespace.
get_item
An item getter used when resolving a Liquid path.
Override this to change the behavior of .first
, .last
and .size
.
get_item_async
async
An async item getter for resolving paths.
get_output_buffer
Return a new output buffer respecting any limits set on the environment.
get_size_of_locals
Return the "size" or a "score" for the current local namespace.
This is used by the optional local namespace resource limit. Override
get_size_of_locals
to customize how the limit is calculated. Be sure
to consider self.local_namespace_size_carry
when writing a custom
implementation of get_size_of_locals
.
The default implementation uses sys.getsizeof()
on each of the local
namespace's values. It is not a reliable measure of size in bytes.
loop
Just like Context.extend
, but keeps track of ForLoop objects too.
parentloop
Return the last ForLoop object from the loop stack.
raise_for_loop_limit
Raise a LoopIterationLimitError
if loop stack is bigger than the limit.
resolve
Resolve variable name in the current scope.