Jinja CLI (current version 1.2.2) provides a command-line interface for rendering Jinja2 templates. It allows users to pass data via JSON, YAML, or environment variables and render templates directly from the terminal. The project is actively maintained with infrequent but stable releases, primarily serving as a wrapper for Jinja2.
pip install jinja-cliVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates creating a simple Jinja2 template file and then rendering it from the command line using `jinja-cli`, passing data via the `--data` flag.
Be mindful of the data loading order: `--env` -> `--yaml-data` -> `--json-data` -> `--data`. Use `--verbose` or print the data within your template to debug unexpected values.
For complex data, prefer using `--json-data FILENAME.json` or `--yaml-data FILENAME.yaml` to load data from a file, which avoids shell escaping issues. If using `--data`, ensure the string is correctly quoted and escaped for your shell.
To disable auto-escaping for a specific variable, use the `| safe` filter: `{{ my_html_content | safe }}`. To disable auto-escaping for the entire template, use `{% autoescape false %}` and `{% endautoescape %}` blocks within the template, or specify `--no-autoescape` CLI option (though this option is not explicitly listed in common usage, it's a Jinja2 concept).