Render parameterized Jinja2 template files
Project description
inji
Render static jinja2 template files, optionally specifying parameters contained in vars files.
Useful in CI/CD scenarios to keep configuration DRY across environments.
Installation
NOTE: Support for Python2 is now dropped. Python3 is required.
pip install inji
Usage
Render a lone Jinja2 template.
inji --template=jello-world.j2
Render a template passing vars from a YAML file.
inji --template=motd.j2 --vars-file=production.yaml
vars files must contain valid YAML documents and can hold either simple scalars or collections. Your jinja templates must reference these accordingly.
e.g.
$ cat vars.yaml
sage: victor
section: indigo
envoy:
names:
- alice
- bob
- chuck
location: metaverse
origin: world's end
$ cat hello-world.j2
Hello {{ envoy.names | join(', ') }}!!
I am {{ sage }}, the {{ section }} sage.
It seems you are at {{ envoy.location }} today and come from {{ envoy.origin }}.
$ inji -t hello-world.j2 -v vars.yaml
Hello alice, bob, chuck!!
I am victor, the indigo sage.
It seems you are at metaverse today and come from world's end.
Render a template using variables from multiple vars files
inji --template=nginx.conf.j2 \
--vars-file=web-tier.yaml \
--vars-file=eu-west-1.yaml \
--vars-file=prod.yaml > /etc/nginx/sites-enabled/prod-eu-west-1.conf
This is especially useful in managing layered configuration. i.e. variables from files specified later on the command-line will be overlain over those defined earlier.
Etymology
inji is named in keeping of the UNIX tradition of short (memorable?) command names.
inji (/ɪndʒi:/) also happens to be the Tamil word for Ginger. In this case, it is a near-anagram of Jinja which ostensibly is a homophone of Ginger (Zingiber).
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
Built Distributions
Hashes for inji-0.2.1.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cebcf83b95e39dc7186e7a6247c212248bb341421f3c04afad0c45b0e2d7fa91 |
|
MD5 | bf7345a4477a241e4358a3cbaf11b41d |
|
BLAKE2b-256 | 1641a2460ec15a06c787f54a09b686592e7fbc0bafb354d16559e46bb3c2fcd7 |