merge strings in template

2,224 views
Skip to first unread message

Jakub Veverka

unread,
Dec 25, 2014, 11:33:34 AM12/25/14
to confd...@googlegroups.com
Hi,

I am not very familiar with golang template so this might be real easy to answer :)

I have following etcd structure:

/app/customer1/dev
/app/customer1/test
/app/customer2/dev
/app/customer2/test

I would like to read values for all customers, so I am looking for the way to loop through these in confd template.
I've started with following:

{{ $path := "/app/" }}
{{ range ls $path }}
{{$customer := .}}
customer: {{join $path, $customer}}
{{end}}

My problem is that join is not working for me, I have version 0.7.1, not sure if its merged in this version already.

Is there simpler way to iterate through such structure?

Thanks,
Jakub

Jakub Veverka

unread,
Jan 2, 2015, 8:47:04 AM1/2/15
to confd...@googlegroups.com
Ok, this was more golang template question, but I will post my solution here anyway.

Strings can be easily merged in template using printf function:

{{ $customer := printf "%s/%s" "string1" "string2" }}
Reply all
Reply to author
Forward
0 new messages