Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inji-0.2.1.post1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distributions

inji-0.2.1.post1-py3.8.egg (4.9 kB view details)

Uploaded Source

inji-0.2.1.post1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file inji-0.2.1.post1.tar.gz.

File metadata

  • Download URL: inji-0.2.1.post1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for inji-0.2.1.post1.tar.gz
Algorithm Hash digest
SHA256 58821d555bb08922b358c75378d9279117a1b53d813558368bf9bd48cefd3481
MD5 706dc5e6d49646cf3b2283afac9d4169
BLAKE2b-256 5770cc206c7acb20784c99293b9edbe5562e7bcfa9bb4491b3fe6afe7d27e251

See more details on using hashes here.

File details

Details for the file inji-0.2.1.post1-py3.8.egg.

File metadata

  • Download URL: inji-0.2.1.post1-py3.8.egg
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for inji-0.2.1.post1-py3.8.egg
Algorithm Hash digest
SHA256 3ca934b150f89615ac381524a2045a11b70b730b95ff7fc14f2e93fd1e0ec4d1
MD5 71efa3f083de91ec379c1f23ec13c7ae
BLAKE2b-256 6ef0c08f6b3173accf4a19e41b66c661d6b6c9a6419c68fe7f80416ce2e6241b

See more details on using hashes here.

File details

Details for the file inji-0.2.1.post1-py3-none-any.whl.

File metadata

  • Download URL: inji-0.2.1.post1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for inji-0.2.1.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb698b166f9657c5546ac668328cb07deeb3cabcc30efb4e10824a026e9232bd
MD5 2e5dd6907309b6a71dbc85ea411c05ec
BLAKE2b-256 4d74a0593c61e8ae84d60079e78344e005d061a57c71f065728b6d237d8dba6e

See more details on using hashes here.

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