templatetool

command module
v0.0.0-...-7f74b10 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: MIT Imports: 10 Imported by: 0

README

Usage

go get github.com/mgnsk/templatetool

Set TPL_GLOB to the glob of templates. STREAM=1 can be used to render a template with data from a json stream.

Examples

Example templates defined in example.tpl

$ TPL_GLOB=*.tpl go run main.go
Template lister and renderer.

Usage:
   [command]

Available Commands:
  MapTemplate 
  Template1   
  Template2   
  help        Help about any command

Flags:
  -h, --help   help for this command

Use " [command] --help" for more information about a command.

List variables in a template:

$ TPL_GLOB=*.tpl go run main.go Template1
Error: required flag(s) "MyVar1" not set
Usage:
   Template1 [flags]

Flags:
      --MyVar1 string   MyVar1
  -h, --help            help for Template1

required flag(s) "MyVar1" not set
exit status 1

To render, set the variables:

$ TPL_GLOB=*.tpl go run main.go Template1 --MyVar1 test
test

See example_once.sh and example_stream.sh to see how to deal with array/slice/map variables or JSON streaming from standard input.

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