A custom YAML tag for Jinja2 template
Project description
jinjyaml
Application specific YAML tag of Jinja2 template
Usage
>>> from pprint import pprint
>>> import yaml
>>> from jinjyaml import JinjyamlConstructor, jinjyaml_render
>>>
>>> txt = '''
... array:
... !jinja2 |
... {% for n in range(3) %}
... - sub{{n}}: {{loop.index}}
... {% endfor %}
... '''
>>>
>>> loader_class = yaml.FullLoader
>>> constructor = JinjyamlConstructor()
>>> loader_class.add_constructor('!jinja2', constructor)
>>> obj = yaml.load(txt, loader_class)
>>> rendered = jinjyaml_render(obj, loader_class)
>>> pprint(rendered)
{'array': [{'sub0': 1}, {'sub1': 2}, {'sub2': 3}]}
CHANGELOG
v0.1
An early version, maybe not stable enough.
AUTHORS
-
Liu Xue Yan (liu_xue_yan@foxmail.com)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jinjyaml-0.1.tar.gz
(16.1 kB
view hashes)
Built Distribution
jinjyaml-0.1-py3-none-any.whl
(6.9 kB
view hashes)