{"id":9846,"library":"jinja-cli","title":"Jinja CLI","description":"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.","status":"active","version":"1.2.2","language":"en","source_language":"en","source_url":"https://github.com/cykerway/jinja-cli","tags":["jinja2","cli","templating","command-line"],"install":[{"cmd":"pip install jinja-cli","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core templating engine used by jinja-cli.","package":"jinja2","optional":false}],"imports":[{"note":"jinja-cli is not designed for direct import as a Python library. It provides the `jinja` command for shell usage. For programmatic Jinja2 templating, directly import `jinja2`.","symbol":"jinja-cli","correct":"This package is primarily a command-line interface tool."}],"quickstart":{"code":"echo \"Hello {{ name }}! Today is {{ day }}.\" > template.j2\njinja --data '{\"name\": \"World\", \"day\": \"Friday\"}' template.j2","lang":"bash","description":"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."},"warnings":[{"fix":"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.","message":"When providing data via multiple sources (e.g., --env, --yaml-data, --json-data, --data), there's a specific precedence. Environment variables (--env) are loaded first, followed by YAML files, then JSON files, and finally inline --data strings. Later sources override earlier ones for conflicting keys.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Passing complex JSON or YAML data directly via the `--data` flag can require careful shell escaping, especially with nested structures, quotes, or special characters. Incorrect escaping can lead to parsing errors or truncated data.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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).","message":"By default, Jinja2 (and thus `jinja-cli`) auto-escapes HTML characters in variables. This is generally a security feature, but it can be unexpected if you intend to output raw HTML or certain characters.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"First, ensure `jinja-cli` is installed: `pip install jinja-cli`. If it's installed but still not found, check your PATH. Python often installs scripts to `~/.local/bin` on Linux/macOS or `Scripts` subdirectory in your Python install path on Windows. Add this directory to your PATH.","cause":"The `jinja-cli` package is not installed, or the directory where pip installs executables is not included in your system's PATH environment variable.","error":"jinja: command not found"},{"fix":"Review your `--data` string for syntax errors (missing quotes, commas, brackets). For complex data, it's often safer to save it to a `.json` file and use `jinja --json-data your_data.json template.j2` instead of inline `--data`.","cause":"The string provided to the `--data` flag is not valid JSON, or it contains unescaped characters that are being misinterpreted by the shell.","error":"Error: --data parameter must be a valid JSON string."},{"fix":"Always provide the path to your template file as the first positional argument, e.g., `jinja my_template.j2 --data '{\"key\":\"value\"}'`.","cause":"You ran the `jinja` command without providing the path to a Jinja2 template file.","error":"Error: No template specified."}]}