Application specific YAML tag of Jinja2 template
Project description
jinjyaml
Application specific tag of Jinja2 template in PyYAML
Usage
>>> import yaml
>>> import jinjyaml
>>>
>>> txt = '''
... array:
... !j2 |
... {% for i in range(n) %}
... - sub{{i}}: {{loop.index}}
... {% endfor %}
... '''
>>>
>>> constructor = jinjyaml.Constructor()
>>> yaml.add_constructor('!j2', constructor)
>>> obj = yaml.load(txt, yaml.Loader)
>>> data = jinjyaml.extract(obj, {'n': 3})
>>>
>>> print(data)
{'array': [{'sub0': 1}, {'sub1': 2}, {'sub2': 3}]}
CHANGELOG
0.2a1
Many APIs changed in v0.2
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.