tmpl

command module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2021 License: MIT Imports: 14 Imported by: 0

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:

$ go get github.com/benbjohnson/tmpl

Then run tmpl against your desired templates:

$ 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.

$ echo '["foo","bar","baz"]' > tmpldata
$ tmpl -data=@tmpldata my.tmpl

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL