Skip to main content

Jinja2 Template CLI

Project description

Travis CI Python Package Index Code Style: Black

Render Jinja2 templates on the command line using a YAML, JSON or HCL file as input for the render context.

💽 Installation

j2y is installed using pip:

$ pip install j2y

Alternatively you can install directly from Github master branch:

$ pip install git+

👩‍💻 Usage

By default, j2y takes a YAML file as input:

$ j2y template.j2 < values.yaml

Alternatively you can use JSON or HCL as input format:

$ j2y template.j2 -f json < values.json
$ j2y template.j2 -f hcl < values.hcl

It’s also possible to provide multiple input files:

$ j2y template.j2 --context v1.yaml --context v2.yaml

Run j2y -h to see all available options.

Template Variables

Additionally to the variables provided by the input file, j2y also provides built-in default variables. These variables are:

Type: datetime

Value: Current UTC datetime object


Type: dict

Value: Output of platform.uname()


Type: dict

Value: All environment variables (output of os.environ).

⚗️ Local Development


Create a virtualenv and install the package as develop egg:

$ python -m venv env
$ source env/bin/activate
(env) $ pip install -e .


At the moment there are very simple test cases only. Test are written as Python doctests and run using pytest:

(env) $ pip install -e ".[test]"
(env) $ pytest

Pytest additionally runs the black linter and mypy static type checker.

The tests located in the docs/ folder can also be built into HTML using Sphinx:

(env) $ sphinx-build -E -W docs/ _build/

Project details

Download files

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

Files for j2y, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size j2y-0.2.1-py2.py3-none-any.whl (9.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size j2y-0.2.1.tar.gz (13.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page