Skip to content

tnyeanderson/timplit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timplit

This is as easy as it gets! A minimal CLI for go templates.

Read JSON/YAML data from stdin and apply it to the template file. Alternatively, read the template from stdin and the JSON/YAML data from a file.

Functions from sprig are included and available in timplit.

Installation

go install github.com/tnyeanderson/timplit@latest

Usage

See usage with timplit -h.

Examples

# Read JSON from stdin and apply it to a template file
cat data.json | timplit template.tmpl

# Same as above
timplit -t template.tmpl <data.json

# Read JSON from a file and apply it to the template from stdin
timplit -j data.json <template.tmpl

# Read YAML from a file and apply it to the template from stdin
timplit -y data.yaml <template.tmpl

# Read YAML from stdin and apply it to a template file
timplit -Y template.tmpl <data.yaml

# Apply template for each line of JSON
tail -f /some/log.json | timplit -m template.tmpl

# Apply template for each YAML document (separated by "---")
# Multidoc is always supported for YAML (no need for "-m")
tail -f deployment.yaml | timplit -Y template.tmpl

Example JSON/YAML/template files are available in cmd/testdata.