Skip to content

bookerzzz/rendr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rendr

Execute any (Go) template with a given dataset list (JSON) and output results to stdout or to file(s)

The intention of this tool is to output multiple similar files based on a given template with differences provided as attributes in the array of data objects in the given data.json file.

Install

go install github.com/bookerzzz/rendr

Usage

See the example folder for a complete overview.

rendr [--global(-g)='{"GlobalKey":"GlobalValue"}'] path/to/data.json path/to/template.tmpl path/to/output/dir/filename.ext

You may also use data values from the data.json file entries so if your data contains

[
  {
    "Dir", "my/output/dir",
    "Filename": "myoutputfile.txt"
  }
]

you can run

rendr path/to/data.json path/to/template.tmpl "{{ .Dir }}/{{ .Filename }}"

to create ./my/output/dir/myoutputfile.txt with results of template.tmpl after rendering. If the path to the output file doesn't exists, Rendr will attempt to create it.

You may also use/inject the global values into the data.json file, so render will first apply global values to the given data.json file before parsing it and providing the resolved set of data to the template for execution.

rendr [--global(-g)='{"FileExt":"txt"}'] data.json path/to/template.tmpl path/to/output/dir/filename.ext
// data.json
[
  {
    "Dir", "my/output/dir",
    "Filename": "myoutputfile.{{ .FileExt }}"
  }
]

About

Execute any (Go) template with a given dataset list (JSON) and output results to stdout or to file(s)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published