#env-file #tera-templates #interpolation #context #one-off

app tera-cli

Tera CLI for one-off template interpolation from context file / env vars

8 releases (4 breaking)

0.5.0 Jan 10, 2023
0.4.1 Apr 21, 2020
0.4.0 Mar 30, 2020
0.3.0 Jan 5, 2020
0.1.1 Apr 25, 2019

#282 in Value formatting

Download history 42/week @ 2025-08-26 2/week @ 2025-09-02 27/week @ 2025-09-09 33/week @ 2025-09-16 40/week @ 2025-09-23 52/week @ 2025-09-30 49/week @ 2025-10-07 56/week @ 2025-10-14 76/week @ 2025-10-21 56/week @ 2025-10-28 44/week @ 2025-11-04 69/week @ 2025-11-11 42/week @ 2025-11-18 38/week @ 2025-11-25 39/week @ 2025-12-02 29/week @ 2025-12-09

154 downloads per month

MIT license

18KB
288 lines

Tera CLI

CI Status Crates.io License: MIT

Tera CLI for one-off template interpolation from context file / env vars.

The following context formats are supported:

  • JSON context file (--json . defaults to .tera.json)
  • TOML context file (--toml . defaults to .tera.toml)
  • YAML context file (--yaml . defaults to .tera.yaml)
  • Environment variables

Changelog

See CHANGELOG.md.

Simple Examples

TOML

Template template.tmpl

{% if hello %}{{ msg }}{% endif %}

TOML .tera.toml

hello = true
msg = "Hello World!"

STDOUT

> tera -f template.tmpl --toml .
Hello World!

> cat template.tmpl | tera --toml .
Hello World!

> tera -s "$(cat template.tmpl)" --toml .
Hello World!

Environment Variables

Template template.tmpl

{% if MSG %}{{ MSG }}{% endif %}

STDOUT

> MSG="Hello World!" tera -f template.tmpl --env
Hello World!

By default, setting --toml . looks for .tera.toml context file in current working directory. Similarly, setting --json . looks for .tera.json in current working directory. Use --toml file_to_toml to change the path to the context file.

For more details, run

tera --help

Acknowledgement

Thanks to original Tera author, whose GitHub repository is at: https://github.com/Keats/tera.

Also thanks to BurntSushi and his ripgrep repository showcase of GitHub Actions for cross-compilation, which has been copied and adapted heavily into this repository. The original files are here: https://github.com/BurntSushi/ripgrep/tree/8905d54a9f25f4c1e4e3ca8331f517473e174d87/.github/workflows.

Dependencies

~10–15MB
~271K SLoC