Templater is a cli tool that helps you to quickly and easily create files from templates, using go template.
- Inline variables
# File using helm templating
cat <<'EOF'>file
---
{{- $name := "John" }}
class:
{{- range $i := until 11 }}
{{$i}}: {{$name}}
{{- end }}
EOF
templater -i file
# This will be the output
File: out/file
---
class:
0: John
1: John
2: John
3: John
4: John
5: John
6: John
7: John
8: John
9: John
10: John
- Passing variables from external yaml, using helm style templating.
# Value file
cat <<'EOF'>values.yaml
school: Govt. Public School
EOF
# File using helm templating
cat <<'EOF'>file
---
{{- $name := "John" }}
class:
school: {{ .Values.school }}
{{- range $i := until 11 }}
{{$i}}: {{$name}}
{{- end }}
EOF
templater -i file -f values.yaml -o out/
# This will be the output
File: out/file
---
class:
school: Govt. Public School
0: John
1: John
2: John
3: John
4: John
5: John
6: John
7: John
8: John
9: John
10: John
- Using stdin
# Value file
cat <<'EOF'>values.yaml
name: Rajesh
EOF
echo "hi: {{.Values.name}}" | templater -f values.yaml -i -
output:
hi: Rajesh
- HomeBrew
brew install rjshrjndrn/tap/templater
- Binary
Download the latest binary from Release Page.
- Using go get
go get github.com/rjshrjndrn/templater