Skip to content

Instantly share code, notes, and snippets.

@ssmythe
Created July 30, 2019 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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