jinjyaml.functions module¶
- jinjyaml.functions.extract(obj: Any, loader_type: Type[_Loader | _CLoader], env: jinja2.Environment | None = None, context: Mapping[str, Any] | None = None, inplace: bool = False) Any[source]¶
Recursively render and parse template tag objects in a YAML document tree.
This function processes an object that may contain
Datainstances, such as lists or dictionaries. It can handle the following types of input:- A mapping or sequence object returned by a PyYAML Loader:
Recursively searches for
Dataobjects withinobj.Renders the
Data.sourceattribute as a string source for ajinja2.Template.Parses the rendered string using the same PyYAML Loader that loaded
obj.Returns the entire
objwithDataobjects replaced by their corresponding parsed Python objects.
- A single
Dataobject: Renders its
Data.sourceattribute as a string source for ajinja2.Template.Parses the rendered string using the same PyYAML Loader that loaded
obj.Returns the parsed Python object.
- A single
- Other scalar objects returned by a PyYAML Loader:
Directly returns
objwithout any changes.
Note
- Parameters:
obj (Any) – An object that may contain
Datainstances.loader_type (Type[Union[_Loader, _CLoader]]) – The PyYAML Loader used to load
obj.env (Optional[jinja2.Environment]) – The
jinja2.Environmentfor template rendering (optional).context (Optional[Mapping[str, Any]]) – A dictionary of variable name-value pairs for
jinja2template rendering (optional).inplace (bool) –
Whether to perform an in-place replacement of
Dataobjects withinobj.
- Returns:
The final parsed and extracted Python object.
- Return type:
Any