Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
/ templatetool Public archive

Go template lister and renderer. Render templates on the fly by passing variables as flags or streaming JSON from stdin to rendering an array of objects.

License

Notifications You must be signed in to change notification settings

mgnsk/templatetool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Go template lister and renderer. Render templates on the fly by passing variables as flags or streaming JSON from stdin to rendering an array of objects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published