Categorygithub.com/dpb587/gotmpl
repositorypackage
0.1.0
Repository: https://github.com/dpb587/gotmpl.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# 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