gotmpl

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: MIT Imports: 10 Imported by: 0

README

gotmpl

A lightweight tool for rendering Go templates from the command line.

Command Line Usage

Pass the template file(s) and they will be rendered to standard out.

$ gotmpl /app/etc/wp-config.php.tmpl

Templates may use sprig functions.

define('DB_HOST', {{ squote ( env "WORDPRESS_DB_HOST" ) }});

Inline templates may be used with the --template option.

$ gotmpl \
  --template '{{ now | date "2006-01-02" }}'

External data from files or URLs may also be used (JSON, YAML, or raw).

$ gotmpl \
  --json data.json \
  --template '{{ .location }}'

Multiple data sources may be used by prefixing the source with a key.

$ gotmpl \
  --json jdat=data.json \
  --yaml ydat=data.yaml \
  --template '{{ .jdat.location }} vs {{ .ydat.location }}'

Output may be redirected elsewhere (or to multiple copies).

$ gotmpl template.tmpl \
  --output /mnt/mirror-1/result.txt \
  --output /mnt/mirror-2/result.txt

Outputs may specify a block name to render different things to files.

$ gotmpl templates/*.tmpl \
  --output summary.txt=summary \
  --output results.csv=csv

Use --help to see the full list of options for more advanced usage.

Installation

Binaries for Linux, macOS, and Windows can be downloaded from the releases page. A Homebrew recipe is also available for Linux and macOS.

brew install dpb587/tap/gotmpl

Alternatives

License

MIT License

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
pkg
app

Jump to

Keyboard shortcuts

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