title: How to concatenate Service metadata for consul-template with commas
body: <p>Does anyone know how to concatenate strings from consul for consul-template? </p>
  
  <p>If I have a service 'foo' registered in Consul</p>
  
  <pre><code>{
    "Node": "node1",
    "Address": "192.168.0.1",
    "Port": 3333
  },
  {
    "Node": "node2",
    "Address": "192.168.0.2",
    "Port": 4444
  }
  </code></pre>
  
  <p>I would like consul-template to generate the following line:</p>
  
  <pre><code>servers=192.168.0.1:3333,192.168.0.2:4444/bogus
  </code></pre>
  
  <p>The following attempt does not work since it leaves a trailing comma <code>,</code></p>
  
  <pre><code>servers={{range service "foo"}}{{.Address}}{{.Port}},{{end}}/bogus
  # renders
  servers=192.168.0.1:3333,192.168.0.2:4444,/bogus
  
  # What I actually want
  servers=192.168.0.1:3333,192.168.0.2:4444/bogus
  </code></pre>
  
  <p>I know consul-template uses golang template syntax, but I simply cannot figure out the syntax to get this working. Its likely that I should use consul-template's <code>join</code> but how do I pass both <code>.Address</code> and <code>.Port</code> to <code>join</code>? This is just a trivial example, and I'm not using indexes intentionally since the number of services could be more than two. Any ideas?</p>