https://github.com/benbjohnson/tmpl
Command line interface to Go's text/template library.
https://github.com/benbjohnson/tmpl
Last synced: 10 months ago
JSON representation
Command line interface to Go's text/template library.
- Host: GitHub
- URL: https://github.com/benbjohnson/tmpl
- Owner: benbjohnson
- License: mit
- Created: 2015-12-17T16:32:52.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2021-03-31T17:41:24.000Z (almost 5 years ago)
- Last Synced: 2025-03-15T23:56:17.475Z (10 months ago)
- Language: Go
- Size: 23.4 KB
- Stars: 84
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tmpl
This program is a command line interface to Go's `text/template` library. It
can be used by passing in a set of JSON-encoded data and a list of template
paths ending in a `.tmpl` extension. The templates are processed and their
results are saved to the filename with the `.tmpl` extension removed.
## Getting Started
To install `tmpl`, simply run:
```sh
$ go get github.com/benbjohnson/tmpl
```
Then run `tmpl` against your desired templates:
```sh
$ tmpl -data '["foo","bar","baz"]' a.go.tmpl b.go.tmpl
```
You will now have templates generated at `a.go` and `b.go`.
### Template data files
Once your data set gets larger, it may be useful to move it to its own file
instead of specifying it on the command line. To use a data file instead
of raw JSON on the command line, use the `-data` argument but prefix your
path with an `@` symbol.
```sh
$ echo '["foo","bar","baz"]' > tmpldata
$ tmpl -data=@tmpldata my.tmpl
```