Skip to main content

Application specific YAML tag of Jinja2 template

Project description

jinjyaml

GitHub tag Test Python Package Documentation Status Quality Gate Status PyPI

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

Project details


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.

Built Distribution

jinjyaml-0.2a1-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page