Skip to content

Instantly share code, notes, and snippets.

@ssmythe
Created July 30, 2019 17:32
Show Gist options
  • Save ssmythe/54bf42dd73e742aacc05ee38d3d0e659 to your computer and use it in GitHub Desktop.
Save ssmythe/54bf42dd73e742aacc05ee38d3d0e659 to your computer and use it in GitHub Desktop.
gomplate output map example
# https://github.com/hairyhenderson/gomplate
# templates/hello.tmpl
Hello, {{ .users.Name }}
# config.json
{
"Name": "Steve"
}
# config.yaml (gomplate supports YAML as well)
Name: Steve
# gomplate --input-dir=templates/ --output-map='outputs/{{ .in | strings.ReplaceAll ".tmpl" "" }}' -c users=config.json
# cat outputs/hello
Hello, Steve
# The key is the context (-c) switch that determines the template namespace to be used. Use "." for root context.
# contexts can be overridden with multiple -c invocations on the same command line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment