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.0b1.tar.gz (10.0 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.0b1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jinja2_cli-1.0.0b1.tar.gz
  • Upload date:
  • Size: 10.0 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.0b1.tar.gz
Algorithm Hash digest
SHA256 d88c253ca0b8d559a51698287e36385a968a96175748ee3d2afc3d50274f85c1
MD5 d564108ff10c3f020e83ac0f1b7b5f0a
BLAKE2b-256 2838dbc7f5136b310b6276dac1c7aaeb86ef1d8cae6ccc541374b9006dfd8fcf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jinja2_cli-1.0.0b1-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.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 6fefb01f2bb74736e0f6a299dfe90cca97bae6a033f9e1bce8a2c80a272ca47c
MD5 b6c81faab419b2f7edf50b900d0c52e5
BLAKE2b-256 bfb9f7fc56237c74c4d4098e4ae6cd2c7ec255a32930a853408dd88706ba589a

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