A CLI tool that uses Go text templates to generate output files from JSON or YAML data sources.
go install github.com/wernerstrydom/render/cmd/render@latest# Render a single template
render config.tmpl values.json -o config.yaml
# Render a directory of templates
render ./templates data.yaml -o ./output
# Generate one file per item
render user.tmpl users.json --item-query '.users[]' -o '{{.username}}.txt'
# Preview without writing
render ./templates data.json -o ./dist --dry-runrender <template-source> <data-source> -o <output> [OPTIONS]
template-source- Path to template file or directorydata-source- Path to JSON or YAML data file
| Flag | Description |
|---|---|
-o, --output |
Output path (required) |
-f, --force |
Overwrite existing files |
--query |
jq expression to transform data |
--item-query |
jq expression to extract items for iteration |
--control |
Path to control file for path mappings |
--dry-run |
Preview without writing files |
--json |
Machine-readable JSON output |
render automatically selects the appropriate mode:
- File mode: Single template → single output
- Directory mode: Template directory → output directory
- Each mode: Template + item query → multiple outputs
See the docs/ directory for comprehensive documentation:
render provides 80+ template functions including:
- Casing:
lower,upper,camelCase,snakeCase,kebabCase,pascalCase - String:
trim,replace,split,join,contains,indent - Conversion:
toString,toInt,toJson,fromJson - Collections:
list,dict,keys,values,merge,sortAlpha - Math:
add,sub,mul,div,max,min - Regex:
regexMatch,regexReplace,regexFind
See Template Functions Reference for the complete list.
Generate and view man pages:
render gen man ./man
man ./man/render.1MIT License - see LICENSE file for details.