• Stars
    star
    2,262
  • Rank 20,357 (Top 0.5 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A flexible commandline tool for template rendering. Supports lots of local and remote datasources.

gomplate logo

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

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

DockerHub Pulls

Chocolatey Chocolatey

Install Docs Slack Discussions

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

Come chat with developers and community in the #gomplate channel on Gophers Slack and on GitHub Discussions!

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, and join the discussion in GitHub Discussions!

Please report any bugs found in the issue tracker.

License

The MIT License

Copyright (c) 2016-2022 Dave Henderson

Analytics

More Repositories

1

go-fsimpl

Go io/fs.FS filesystem implementations for various URL schemes
Go
240
star
2

go-which

A cross-platform Go implementation of the which(1) command, usable both as a CLI and library
Go
41
star
3

caddyprom

⚠️ DEPRECATED - use the core metrics supported in Caddy v2.2.0-rc.2+
Go
28
star
4

caddy-teapot-module

✨ A Caddy (v2) module which responds with "418 I'm a teapot" to all requests.
Go
22
star
5

github-responder

A library & CLI tool that automatically sets up GitHub WebHooks and listens for events, with automatic TLS
Go
21
star
6

go-codeowners

A Go package that finds and parses GitHub CODEOWNERS files
Go
16
star
7

jiraprinter

Print issue cards from JIRA
JavaScript
12
star
8

dockerhub_ratelimit_exporter

A Prometheus-format exporter to report on DockerHub per-image rate limits
Go
10
star
9

dockerfiles

Random Dockerfiles...
Dockerfile
9
star
10

jarvis_exporter

A Prometheus exporter for the Fully Jarvis standing desk
Go
9
star
11

hitron_coda

A Go client for the Hitron CODA-4680 Cable Modem/Router (and possibly others!)
Go
8
star
12

hitron_coda_exporter

A Prometheus Exporter for the Hitron CODA-4680 Cable Modem (and probably others too!)
Go
6
star
13

teams

CLI application to manage github issues and pull requests for multiple repos
Go
5
star
14

scanbar

Look for barcodes in the webcam ¯\_(ツ)_/¯
Go
4
star
15

github-sync-labels-milestones

A port of Xiphe/github-sync-labels-milestones to Golang
Go
4
star
16

go-onerng

⚠️INCOMPLETE⚠️ A Go port of the OneRNG tools
Go
3
star
17

homebrew-tap

A homebrew tap for my stuff
Ruby
3
star
18

radiorelay

Radio Relay project for CEML
3
star
19

markdowntopdf

A markdown-to-PDF conversion tool
Dockerfile
3
star
20

passport-fellowshipone

Passport strategy for authenticating with Fellowship One using the OAuth 1.0a API.
JavaScript
3
star
21

trafficlight

🚦 Controller for a Red/Yellow/Green (+buzzer) Traffic Light on a Raspberry Pi
Go
2
star
22

hairyhenderson

2
star
23

node-fellowshipone

A Fellowship One API wrapper for Node.js
JavaScript
2
star
24

hairyhenderson.github.io

HTML
2
star
25

wnp-bridge

Go
2
star
26

nursery_alert

A Raspberry Pi-based system for displaying alert codes to a screen
JavaScript
1
star
27

oauth2_proxy

Yet another oauth2_proxy image...
Dockerfile
1
star
28

docker-shairport-sync

Dockerfile
1
star
29

arduinostuff

A bunch of random Arduino (and related) sketches and code
Arduino
1
star
30

f1foo

ARCHIVED
JavaScript
1
star
31

cassandra-lucene-docker

1
star
32

sunrise-client

🌅Client for hairyhenderson/wifi-neopixel to run daily sunrise/sunset sequences🌇
Go
1
star
33

go-revendorbot

A bot that works with github-responder to revendor a Go repo on demand
Go
1
star
34

wifi-neopixel

C
1
star
35

linuxkit-configs

some random linuxkit configs that I've been playing with
Shell
1
star
36

dotfiles

Vim Script
1
star
37

hkrelay

A HomeKit-compatible Raspberry Pi Relay controller
Go
1
star
38

henet-ipupdater

🔃 A program that periodically updates dynamic IPs
Shell
1
star
39

GarageMonitor

An Arduino sketch for monitoring the state of a garage door (or, really, the state of any switch).
Arduino
1
star