Skip to content
A flexible commandline tool for template rendering. Supports lots of local and remote datasources.
Branch: master
Clone or download
hairyhenderson Merge pull request #539 from hairyhenderson/docs-search
Adding search functionality to docs site
Latest commit aae1a68 Apr 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
.github
aws
base64 Return error instead of using log.Fatal Sep 25, 2018
cmd/gomplate
coll
conv New collections (coll) namespace, plus new functions Jan 29, 2019
crypto Return error instead of using log.Fatal Sep 25, 2018
data Fixing merge behaviour for booleans Apr 6, 2019
docs-src/content/functions Fixing coll.JSONPath reference in docs Apr 10, 2019
docs Adding search functionality to docs site Apr 16, 2019
env Replacing uses of blang/vfs with spf13/afero Mar 7, 2019
file file.Write should truncate existing files Mar 14, 2019
funcs Adding coll.JSONPath function Apr 10, 2019
hooks Adding alpine Docker image variant Apr 25, 2018
libkv Fix bug where string keys are not sorted as expected Jan 28, 2019
math Adding math.Seq function Nov 3, 2017
net Return error instead of using log.Fatal Sep 25, 2018
random
regexp Adding more regexp functions Nov 28, 2018
strings New strings.WordWrap function Feb 17, 2019
test
tests/integration Adding coll.JSONPath function Apr 10, 2019
time Adding time.ZoneOffset function Nov 1, 2017
tmpl
vault Replacing uses of blang/vfs with spf13/afero Mar 7, 2019
vendor
version
.dockerignore Use upx 3.94 from alpine 3.8 for now Feb 10, 2019
.gitignore Setting up code coverage with codeclimate Jul 17, 2018
CHANGELOG.md
CONTRIBUTING.md Adding more contributing info Jan 29, 2019
Dockerfile Update golang Docker tag to v1.12.4 Apr 12, 2019
Dockerfile.integration Upgrading dependencies Mar 3, 2019
Gopkg.lock
Gopkg.toml Some more Windows fixes (#527) Mar 30, 2019
LICENSE Updating copyright year Mar 15, 2018
Makefile
README.md Moving docs to docs.gomplate.ca Mar 24, 2019
appveyor.yml Some more Windows fixes (#527) Mar 30, 2019
cleanup.go Putting main pkg in cmd subdirectory Apr 18, 2018
config.go Adding --output-map argument for templating output paths Apr 9, 2019
config_test.go Adding --output-map argument for templating output paths Apr 9, 2019
context.go
context_test.go New --context flag for adding datasources to context Nov 15, 2018
funcs.go New random namespace for generating random strings and numbers Mar 17, 2019
gomplate.go
gomplate_test.go Adding --output-map argument for templating output paths Apr 9, 2019
metrics.go Adding basic metrics around template rendering Apr 21, 2018
renovate.json Updating renovate config Dec 22, 2018
template.go
template_test.go
template_unix_test.go Adding --output-map argument for templating output paths Apr 9, 2019
template_windows_test.go

README.md

gomplate logo

Read the docs at docs.gomplate.ca, chat with developers and community in the #gomplate channel on Gophers Slack

Build Status Windows Build Go Report Card Codebeat Status Coverage Total Downloads CII Best Practices

hairyhenderson/gomplate on DockerHub DockerHub Stars DockerHub Pulls DockerHub Image Layers DockerHub Latest Version DockerHub Latest Commit

Install Docs Slack

gomplate is a template renderer which supports a growing list of datasources, such as: JSON (including EJSON - encrypted JSON), YAML, AWS EC2 metadata, BoltDB, Hashicorp Consul and Hashicorp Vault secrets.

Here are some hands-on examples of how gomplate works:

$ # at its most basic, gomplate can be used with environment variables...
$ echo 'Hello, {{ .Env.USER }}' | gomplate
Hello, hairyhenderson

$ # but that's kind of boring. gomplate has tons of functions to do useful stuff, too
$ gomplate -i 'the answer is: {{ mul 6 7 }}'
the answer is: 42

$ # and, since gomplate uses Go's templating syntax, you can do fun things like:
$ gomplate -i '{{ range seq 5 1 }}{{ . }} {{ if eq . 1 }}{{ "blastoff" | toUpper }}{{ end }}{{ end }}'
5 4 3 2 1 BLASTOFF

$ # the real fun comes when you use datasources!
$ cat ./config.yaml
foo:
  bar:
    baz: qux
$ gomplate -d config=./config.yaml -i 'the value we want is: {{ (datasource "config").foo.bar.baz }}'
the value we want is: qux

$ # datasources are defined by URLs, and gomplate is not limited to just file-based datasources:
$ gomplate -d ip=https://ipinfo.io -i 'country code: {{ (ds "ip").country }}'
country code: CA

$ # standard input can be used as a datasource too:
$ echo '{"cities":["London", "Johannesburg", "Windhoek"]}' | gomplate -d city=stdin:///in.json -i '{{ range (ds "city").cities }}{{.}}, {{end}}'
London, Johannesburg, Windhoek, 

$ # and here's something a little more complicated:
$ export CITIES='city: [London, Johannesburg, Windhoek]'
$ cat in.tmpl
{{ range $i, $city := (ds "cities").city -}}
{{ add 1 $i }}: {{ include "weather" (print $city "?0") }}
{{ end }}
$ gomplate -d 'cities=env:///CITIES?type=application/yaml' -d 'weather=https://wttr.in/?0' -H 'weather=User-Agent: curl' -f in.tmpl
1: Weather report: London

    \  /       Partly cloudy
  _ /"".-.     4-7 °C
    \_(   ).   ↑ 20 km/h
    /(___(__)  10 km
               0.0 mm

2: Weather report: Johannesburg

    \  /       Partly cloudy
  _ /"".-.     15 °C
    \_(   ).   ↘ 0 km/h
    /(___(__)  10 km
               2.2 mm

3: Weather report: Windhoek

    \  /       Partly cloudy
  _ /"".-.     20 °C
    \_(   ).   ↑ 6 km/h
    /(___(__)  20 km
               0.0 mm

Read the documentation at docs.gomplate.ca!

Please report any bugs found in the issue tracker.

License

The MIT License

Copyright (c) 2016-2019 Dave Henderson

Analytics

You can’t perform that action at this time.