iterate over plugin's output #1864
Unanswered
yaozongyou
asked this question in
Q&A
Replies: 1 comment
-
|
Hi @yaozongyou, I've moved this issue to a discussion given that it's not a bug report. The basic issue here is that the output from your script is an unparsed string. You need to parse the string as JSON with the Try something like: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, gomplate is really awesome, thanks, it is of great help.
And it works well on the following example:
$ cat cities.json { "cities": ["New York", "Seattle", "Chicago"] } $ cat cities.tmpl {{ range $index, $city := .cities }} {{ $index }} {{ $city }} {{ end }} $ ./gomplate_linux-amd64 -c .=./cities.json -f cities.tmpl 0 New York 1 Seattle 2 Chicagois it possible to get cities from script?
$ ./cities.tmpl {{ range $index, $city := cities }} {{ $index }} {{ $city }} {{ end }} $ cat cities.sh #!/bin/bash echo '["New York", "Seattle", "Chicago"]' $ ./gomplate_linux-amd64 -f ./cities.tmpl --plugin cities=./cities.sh 21:36:51 ERR error="failed to render template ./cities.tmpl: template: ./cities.tmpl:1:26: executing \"./cities.tmpl\" at <cities>: range can't iterate over [\"New York\", \"Seattle\", \"Chicago\"]\n"how to fix this?
Beta Was this translation helpful? Give feedback.
All reactions