Skip to main content

The CLI interface to Jinja2

Project description

$ jinja2

The CLI for Jinja2.

$ jinja2 template.j2 data.json
$ curl -s http://api.example.com | jinja2 template.j2

Install

$ uv tool install jinja2-cli
$ pip install jinja2-cli

Formats

Built-in: JSON, INI, ENV, querystring, TOML (Python 3.11+)

Optional formats via extras:

$ pip install jinja2-cli[yaml]
$ pip install jinja2-cli[xml]
$ pip install jinja2-cli[hjson]
$ pip install jinja2-cli[json5]

Features

  • Read data from files or stdin
  • Define variables inline with -D key=value
  • Custom Jinja2 extensions
  • Import custom filters - see Custom Filters below
  • Full control over Jinja2 environment options

Run jinja2 --help for all options, or see docs/ for full documentation.

Custom Filters

Extend Jinja2 with your own filters or use Ansible's extensive filter library:

# Use custom filters
$ jinja2 template.j2 data.json -F myfilters

# Use Ansible filters
$ jinja2 template.j2 data.json -F ansible.plugins.filter.core

Example filter module:

# myfilters.py
def reverse(s):
    return s[::-1]

def shout(s):
    return s.upper() + "!"

See docs/filters.md for complete documentation and examples.

Used by

Available in

PyPI Homebrew nixpkgs AUR Alpine

Learn more

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

jinja2_cli-1.0.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jinja2_cli-1.0.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file jinja2_cli-1.0.0.tar.gz.

File metadata

  • Download URL: jinja2_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for jinja2_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e7dadec3f908602669b1518245c90a0c08bceecc2c40d35011e3bcb54bcdf52f
MD5 e116ef419986cd05dcd46306f056d671
BLAKE2b-256 cc477d9eb78491492a30d661387abeaf86e1a2b6a6da9d167897173ba4fdcce0

See more details on using hashes here.

File details

Details for the file jinja2_cli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: jinja2_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for jinja2_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 003da79bdddce82a186d98687c77bdecacdb1a5d40d1962df500003d4f4ad03c
MD5 01bc6fb1ff0f51bc957e1bc92b2cff22
BLAKE2b-256 926678c8e9609ed72ccd835870494f119d6afcc5f28f10d06844b581ed38101b

See more details on using hashes here.

Supported by

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