Application specific YAML tag of Jinja2 template
Project description
jinjyaml
Application specific tag of Jinja2 template in PyYAML.
It may be useful if you only want to render special tag nodes in the document, instead of whole YAML string as a template.
Usage
>>> import yaml
>>> import jinjyaml
>>>
>>> yaml.add_constructor('!j2', jinjyaml.Constructor())
>>>
>>> s = '''
... array:
... !j2 |
... {% for i in range(n) %}
... - sub{{i}}: {{loop.index}}
... {% endfor %}
... '''
>>>
>>> obj = yaml.load(s)
>>>
>>> data = jinjyaml.extract(obj, context={'n': 3})
>>> print(data)
{'array': [{'sub0': 1}, {'sub1': 2}, {'sub2': 3}]}
CHANGELOG
0.2
-
Date: 2021-09-08
-
new api
-
update to Jinja2 3.0
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 Distribution
jinjyaml-0.2.0.post1.tar.gz
(6.2 kB
view hashes)
Built Distribution
Close
Hashes for jinjyaml-0.2.0.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1df215d66a4b6ddfc165c3573526f4d810717380d5c03867736711c3cf8ca13d |
|
MD5 | bb2effae1a69c79f0554fe881cf4b2bc |
|
BLAKE2b-256 | 5f6d18e46aa616b1e423ed441761819ff273087f971339c2f34c1ab2732382f4 |