envtpl

raw JSON →
0.8.0 verified Fri May 01 auth: no python

Render Jinja2 templates on the command line using shell environment variables. Installed as a CLI tool, it reads a template file, substitutes variables from the environment, and outputs the result. Current version 0.8.0 (2025-03-21) drops Python 2 support and requires Python >=3.10.

pip install envtpl
error envtpl: error: argument -: expected one argument
cause Running `envtpl` without providing a template (expects stdin or file argument).
fix
Provide input: envtpl < mytemplate.j2 or echo '...' | envtpl.
error jinja2.exceptions.UndefinedError: 'VARIABLE' is undefined
cause Template references a variable not set in the environment.
fix
Set the variable before running: export VARIABLE=value; envtpl template.j2, or use -u flag.
breaking Python 2 dropped in 0.8.0. Requires Python >=3.10.
fix Upgrade to Python 3.10+.
gotcha Undefined variables raise an error by default; use `-u` flag to allow undefined variables.
fix Use `envtpl -u template.j2` to suppress errors for undefined variables.
gotcha Template file must be passed via stdin or as argument; redirect or pipe carefully.
fix Use `envtpl < template.j2` or `cat template.j2 | envtpl`. Do not omit the `<` or pipe.

Create a Jinja2 template and render it with envtpl, passing environment variables.

echo 'Hello {{ NAME }}' > template.j2
NAME=World envtpl < template.j2
# Output: Hello World