jinjyaml.representer module¶
- class jinjyaml.representer.Representer(tag: str)[source]¶
Bases:
objectRepresenter for
jinja2.Templatetags.When dumping an object into a YAML string, this class converts
Dataobjects to their string representation.To add the representer to a PyYAML dumper, use the following code:
representer = jinjyaml.Representer("j2") # Note: No "!" here! yaml.add_representer(Node, representer)
Attention
The tag name passed to the Representer constructor MUST NOT include the leading “!”. This is because PyYAML automatically adds the “!” when registering the representer.
Ensure that Node is the correct type for the objects you want to represent.
- Parameters:
tag (str)