github.com/hairyhenderson/templater@v3.5.0+incompatible/README.md (about)

     1  <img src="docs/static/images/gomplate.png" width="512px" alt="gomplate logo"/>
     2  
     3  _Read the docs at [docs.gomplate.ca][docs-url], chat with developers and community in the [#gomplate channel][] on [Gophers Slack][]_
     4  
     5  [![Build Status][circleci-image]][circleci-url]
     6  [![Windows Build][appveyor-image]][appveyor-url]
     7  [![Go Report Card][reportcard-image]][reportcard-url]
     8  [![Codebeat Status][codebeat-image]][codebeat-url]
     9  [![Coverage][gocover-image]][gocover-url]
    10  [![Total Downloads][gh-downloads-image]][gh-downloads-url]
    11  [![CII Best Practices][cii-bp-image]][cii-bp-url]
    12  
    13  [![hairyhenderson/gomplate on DockerHub][dockerhub-image]][dockerhub-url]
    14  [![DockerHub Stars][dockerhub-stars-image]][dockerhub-url]
    15  [![DockerHub Pulls][dockerhub-pulls-image]][dockerhub-url]
    16  [![DockerHub Image Layers][microbadger-layers-image]][microbadger-url]
    17  [![DockerHub Latest Version ][microbadger-version-image]][microbadger-url]
    18  [![DockerHub Latest Commit][microbadger-commit-image]][microbadger-url]
    19  
    20  [![Install Docs][install-docs-image]][install-docs-url]
    21  [![Slack][slack-image]][slack-url]
    22  
    23  `gomplate` is a template renderer which supports a growing list of datasources,
    24  such as: JSON (_including EJSON - encrypted JSON_), YAML, AWS EC2 metadata, [BoltDB](https://github.com/boltdb/bolt),
    25  [Hashicorp Consul](https://www.consul.io/) and [Hashicorp Vault](https://www.vaultproject.io/) secrets.
    26  
    27  Here are some hands-on examples of how `gomplate` works:
    28  
    29  ```console
    30  $ # at its most basic, gomplate can be used with environment variables...
    31  $ echo 'Hello, {{ .Env.USER }}' | gomplate
    32  Hello, hairyhenderson
    33  
    34  $ # but that's kind of boring. gomplate has tons of functions to do useful stuff, too
    35  $ gomplate -i 'the answer is: {{ mul 6 7 }}'
    36  the answer is: 42
    37  
    38  $ # and, since gomplate uses Go's templating syntax, you can do fun things like:
    39  $ gomplate -i '{{ range seq 5 1 }}{{ . }} {{ if eq . 1 }}{{ "blastoff" | toUpper }}{{ end }}{{ end }}'
    40  5 4 3 2 1 BLASTOFF
    41  
    42  $ # the real fun comes when you use datasources!
    43  $ cat ./config.yaml
    44  foo:
    45    bar:
    46      baz: qux
    47  $ gomplate -d config=./config.yaml -i 'the value we want is: {{ (datasource "config").foo.bar.baz }}'
    48  the value we want is: qux
    49  
    50  $ # datasources are defined by URLs, and gomplate is not limited to just file-based datasources:
    51  $ gomplate -d ip=https://ipinfo.io -i 'country code: {{ (ds "ip").country }}'
    52  country code: CA
    53  
    54  $ # standard input can be used as a datasource too:
    55  $ echo '{"cities":["London", "Johannesburg", "Windhoek"]}' | gomplate -d city=stdin:///in.json -i '{{ range (ds "city").cities }}{{.}}, {{end}}'
    56  London, Johannesburg, Windhoek, 
    57  
    58  $ # and here's something a little more complicated:
    59  $ export CITIES='city: [London, Johannesburg, Windhoek]'
    60  $ cat in.tmpl
    61  {{ range $i, $city := (ds "cities").city -}}
    62  {{ add 1 $i }}: {{ include "weather" (print $city "?0") }}
    63  {{ end }}
    64  $ gomplate -d 'cities=env:///CITIES?type=application/yaml' -d 'weather=https://wttr.in/?0' -H 'weather=User-Agent: curl' -f in.tmpl
    65  1: Weather report: London
    66  
    67      \  /       Partly cloudy
    68    _ /"".-.     4-7 °C
    69      \_(   ).   ↑ 20 km/h
    70      /(___(__)  10 km
    71                 0.0 mm
    72  
    73  2: Weather report: Johannesburg
    74  
    75      \  /       Partly cloudy
    76    _ /"".-.     15 °C
    77      \_(   ).   ↘ 0 km/h
    78      /(___(__)  10 km
    79                 2.2 mm
    80  
    81  3: Weather report: Windhoek
    82  
    83      \  /       Partly cloudy
    84    _ /"".-.     20 °C
    85      \_(   ).   ↑ 6 km/h
    86      /(___(__)  20 km
    87                 0.0 mm
    88  ```
    89  
    90  Read the documentation at [docs.gomplate.ca][docs-url]!
    91  
    92  _Please report any bugs found in the [issue tracker](https://github.com/hairyhenderson/gomplate/issues/)._
    93  
    94  ## License
    95  
    96  [The MIT License](http://opensource.org/licenses/MIT)
    97  
    98  Copyright (c) 2016-2019 Dave Henderson
    99  
   100  [circleci-image]: https://img.shields.io/circleci/project/github/hairyhenderson/gomplate/master.svg?logo=circleci
   101  [circleci-url]: https://circleci.com/gh/hairyhenderson/gomplate/tree/master
   102  [appveyor-image]: https://ci.appveyor.com/api/projects/status/eymky02f5snclyxp/branch/master?svg=true
   103  [appveyor-url]: https://ci.appveyor.com/project/hairyhenderson/gomplate/branch/master
   104  [reportcard-image]: https://goreportcard.com/badge/github.com/hairyhenderson/gomplate
   105  [reportcard-url]: https://goreportcard.com/report/github.com/hairyhenderson/gomplate
   106  [codebeat-image]: https://codebeat.co/badges/39ed2148-4b86-4d1e-8526-25f60e159ba1
   107  [codebeat-url]: https://codebeat.co/projects/github-com-hairyhenderson-gomplate
   108  [gocover-image]: https://gocover.io/_badge/github.com/hairyhenderson/gomplate
   109  [gocover-url]: https://gocover.io/github.com/hairyhenderson/gomplate
   110  [gh-downloads-image]: https://img.shields.io/github/downloads/hairyhenderson/gomplate/total.svg
   111  [gh-downloads-url]: https://github.com/hairyhenderson/gomplate/releases
   112  
   113  [cii-bp-image]: https://bestpractices.coreinfrastructure.org/projects/337/badge
   114  [cii-bp-url]: https://bestpractices.coreinfrastructure.org/projects/337
   115  
   116  [dockerhub-image]: https://img.shields.io/badge/docker-ready-blue.svg
   117  [dockerhub-url]: https://hub.docker.com/r/hairyhenderson/gomplate
   118  [dockerhub-stars-image]: https://img.shields.io/docker/stars/hairyhenderson/gomplate.svg
   119  [dockerhub-pulls-image]: https://img.shields.io/docker/pulls/hairyhenderson/gomplate.svg
   120  
   121  [microbadger-version-image]: https://images.microbadger.com/badges/version/hairyhenderson/gomplate.svg
   122  [microbadger-layers-image]: https://images.microbadger.com/badges/image/hairyhenderson/gomplate.svg
   123  [microbadger-commit-image]: https://images.microbadger.com/badges/commit/hairyhenderson/gomplate.svg
   124  [microbadger-url]: https://microbadger.com/image/hairyhenderson/gomplate
   125  
   126  [docs-url]: https://docs.gomplate.ca
   127  [install-docs-image]: https://img.shields.io/badge/install-docs-blue.svg
   128  [install-docs-url]: https://docs.gomplate.ca/installing
   129  
   130  [Gophers Slack]: https://invite.slack.golangbridge.org
   131  [#gomplate channel]: https://gophers.slack.com/messages/CGTR16RM2/
   132  
   133  [slack-image]: https://img.shields.io/badge/slack-gophers/%23gomplate-00ADD8.svg?logo=slack
   134  [slack-url]: https://gophers.slack.com/messages/CGTR16RM2/
   135  
   136  [![Analytics](https://ga-beacon.appspot.com/UA-82637990-1/gomplate/README.md?pixel)](https://github.com/igrigorik/ga-beacon)