Unfortunately, I'm not working with an array so I am unable to use the index as integer for the beginning of each line in the config as an id(int,auto). However, I am able to get a total of items but am unable to get it working in a range with a loop to capture the iteration in order to insert for each config file line. Any help?
so my template now resembles this:
{{ $total := tree "key/namespace" | byKey | len }}
{{ range $i := loop ($total | printf %d) }}
{{ with tree ($key | printf "key/namespace/%s") | explode }}{{ $i }}:{{ .data }}:{{ .data }}... etc{{ end }}{{ end }}
lines in the config would result as such depending on the number items in top level found when doing byKey
0:55.555.139.136:5555:item0=id1;item1=4000;item2=100:"GW 1"
1:55.555.139.137:5554:item0=id1;item1=4000;item2=100:"GW 2"
having problems when I attempt pass an argument to loop function via interpolation with printf ( unexpected "%" in operand ).
this would accomplish what I'm after if I can figured out how to pass the total iterations to loop to capture the iteration.
I've tried a few things, not sure how to proceed as I keep running into issues with data type.