Yatera

Yet Another Tera CLI

It supports Tera v2, and features rich DX and extra built-in filters.

# Render a template with variables
cat template.tera | tera var1=value var2=value > output.txt

# Use structured data as variables (JSON, TOML, or YAML)
cat template.tera | tera --json '{"hello":"world"}' > output.txt
cat template.tera | tera --json-file vars.json > output.txt

# Read and write files directly (can be used individually)
tera --from template.tera --to output.txt --json-file vars.json

Install yatera

  • macOS/Linux:
    curl -fsSL https://yatera.fyi/install.sh | sh
  • Windows:
    irm https://yatera.fyi/install.ps1 | iex
  • Cargo Binstall:
    cargo binstall yatera

Arguments

The following arguments are available (also see tera --help):

ArgumentDescription
var1=value var2=valueSet template variables from the command line
--json '{"key":"value"}'Set template variables from a JSON string
--json-file vars.jsonSet template variables from a JSON file
--toml-file vars.tomlSet template variables from a TOML file
--toml "$(cat vars.toml)"Set template variables from a TOML string
--yaml-file vars.yamlSet template variables from a YAML file
--yaml "$(cat vars.yaml)"Set template variables from a YAML string
--from template.teraRead the template from a file instead of stdin
--to output.txtWrite the rendered result to a file instead of stdout

Built-Ins

heck

heck methods are available as string filters:

printf '{{ name | to_snake_case }}' | tera name="Hello World"
#=> hello_world
FilterResult for Hello World
to_upper_camel_case / to_pascal_caseHelloWorld
to_lower_camel_casehelloWorld
to_snake_casehello_world
to_kebab_casehello-world
to_shouty_snake_caseHELLO_WORLD
to_shouty_kebab_caseHELLO-WORLD
to_title_caseHello World
to_train_caseHello-World