A Fast and Flexible Template Fill CLI Tool.
Enter the following information to output the text that fills the template.
- a template written in the format text/template
- variables by JSON
go install github.com/korosuke613/tempura@latest
docker pull ghcr.io/korosuke613/tempura
Download from Releases.
using binary
❯ tempura --input-string '{"Name": "John", "Message": "Good"}' --template-string 'Hello {{.Name}}, {{.Message}}'
Hello John, Good
or using docker
❯ docker run --rm ghcr.io/korosuke613/tempura --input-string '{"Name": "John", "Message": "Good"}' --template-string 'Hello {{.Name}}, {{.Message}}'
Hello John, Good
❯ tempura \
--input-string '{"Name": "John", "Message": "Good"}' \
--template-string \
'Hello {{.Name}},
{{.Message}}'
Hello John,
Good
input.json
{
"Name": "John",
"Message": "Good"
}
template.tmpl
Hello {{.Name}},
{{.Message}}
❯ tempura -i input.json -t template.tmpl
Hello John,
Good
❯ tempura -o ./output.txt
❯ cat ./output.txt
Hello John,
Good
https://golang.org/pkg/text/template/#hdr-Actions
input.json
{
"isTrue": true,
"Cat": "cat"
}
template.tmpl
{{if .isTrue}}isTrue is True!{{end}}
{{if .isFalse}}never{{else}}isFalse is False!{{end}}
{{if eq .Cat "cat"}}Cat: nyan{{end}}
❯ tempura
isTrue is True!
isFalse is False!
Cat: nyan
❯ tempura -h
A Fast and Flexible Template Fill CLI Tool built with love by korosuke613 in Go.
Usage:
tempura [flags]
Flags:
-h, --help help for tempura
-i, --input-filepath string input file name (default "input.json")
--input-string string input string
-o, --output string output file name
-t, --template-filepath string template file name (default "template.tmpl")
--template-string string template string
-v, --version show version