derek-schaefer / rtmpl

A command-line template rendering utility.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rtmpl

A command-line template rendering utility.

Usage

Create a template.

$ cat example.tmpl
{{ env "NAME" }}
{{ range .numbers }}
  {{ . }}
{{ end }}

Create some JSON data.

$ cat example.json
{
  "numbers": [1, 2, 3]
}

Render the template.

$ export NAME=test
$ rtmpl -d example.json example.tmpl
test
  1
  2
  3

Data can also be read from stdin.

$ export NAME=test
$ cat example.json | rtmpl -i example.tmpl
test
  1
  2
  3

Multiple templates can be included:

$ cat example1.tmpl
{{ env "NAME" }}
{{ template "example2.tmpl" . }}
$ cat example2.tmpl
{{ range .numbers }}
  {{ . }}
{{ end }}
$ export NAME=test
$ rtmpl -d example.json example1.tmpl example2.tmpl
test
  1
  2
  3

Installation

Binary:

Check the "releases" page.

Go:

$ go get github.com/derek-schaefer/rtmpl

Docker:

$ docker pull derekschaefer/rtmpl

Template Reference

The template syntax is provided by Go's text.Template package.

Additional helpers:

License

MIT

About

A command-line template rendering utility.


Languages

Language:Go 82.0%Language:Makefile 13.1%Language:Shell 4.9%