Created
July 29, 2014 23:23
-
-
Save billhathaway/c745afd7fa334e76923a to your computer and use it in GitHub Desktop.
joining strings in confd templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
With confd sometimes you will want to join a bunch of keys together into a line with comma separated values. Here is a template snippet to do that: | |
servers={{range $index,$server := .myapp_servers}}{{if $index}},"{{$server.Value}}"{{else}}"{{$server.Value}}"{{end}}{{end}} | |
Credit for the technique goes to Jan Newmarch's tutorial page at http://jan.newmarch.name/go/template/chapter-template.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment