Yatera
Yet another Tera template v2 CLI.
It features rich DX and extra built-ins.
Installation
macOS/Linux
Install Yatera on macOS or Linux by running the following command in your terminal:
|
Windows
Install Yatera on Windows by running the following command in PowerShell:
irm https://yatera.fyi/install.ps1 | iex
Cargo Binstall
Install Yatera using Cargo Binstall by running the following command in your terminal:
Build from Source
To compile Yatera from source code, install Rust and then install Yatera using Cargo:
Usage
Use the tera command to render templates from stdin:
# Render a template with variables:
|
# Use structured data as variables (JSON/TOML/YAML):
|
|
# Read and write files directly:
Environment sources parse the variable's contents as JSON, TOML, or YAML. Choose
one structured context source; name=value arguments override its values.
Missing variables or invalid context contents produce an error.
Input
By default Yatera reads the template from stdin. You can override this behavior by using the --in-file option to specify a template file:
Output
By default Yatera writes the rendered result to stdout. You can override this behavior by using the --out-file option to specify an output file:
Variables
Yatera supports multiple ways to provide template variables, from passing arguments to JSON/TOML/YAML strings or files.
Argument Variables
To provide template variables directly as command-line arguments, use the name=value format:
|
Alternatively, use repeatable --var NAME VALUE flags, or the jq-compatible
--arg NAME VALUE alias:
|
|
Variable Files
To read variables from JSON/TOML/YAML files:
|
CLI options:
| Argument | Format |
|---|---|
--json-file vars.json |
JSON |
--toml-file vars.toml |
TOML |
--yaml-file vars.yaml |
YAML |
Variable Strings
To read variables from JSON/TOML/YAML strings:
|
CLI options:
| Argument | Format |
|---|---|
--json '{"var":"value"}' |
JSON |
--toml "$(cat vars.toml)" |
TOML |
--yaml "$(cat vars.yaml)" |
YAML |
Environment Variable Strings
Yatera also supports reading variables from JSON/TOML/YAML strings stored in environment variables:
|
CLI options:
| Argument | Format |
|---|---|
--json-env VARS |
JSON |
--toml-env VARS |
TOML |
--yaml-env VARS |
YAML |
Built-Ins
Yatera supports all default Tera built-ins as well as extra filters.
Extra Filters
heck
heck methods are available as string filters:
|
#=> hello_world
| Filter | Result for Hello World |
|---|---|
upper_camel_case / pascal_case |
HelloWorld |
lower_camel_case |
helloWorld |
snake_case |
hello_world |
kebab_case |
hello-world |
shouty_snake_case |
HELLO_WORLD |
shouty_kebab_case |
HELLO-WORLD |
train_case |
Hello-World |