I know that
the
template
action allows you to pass in a second argument that will be assigned to the dot (.
) argument inside of the template.
-- https://www.calhoun.io/intro-to-templates-p2-actions/
However, I need to loop over my nested template, and I need to pass the current loop number to the nested template, apart from the rest of the existing arguments.
Let me explain with my example -- https://play.golang.org/p/Y7OIxM9t-XU
- In line 62, you can see that I need a bunch of arguments, e.g.
{{.a}}{{.b}}
, in my nested template. - In line 64, I tried to pass the current loop number
$val
as the extra to the existing arguments passing to my nested template. That's where it fails -- If I remove line 64, it runs fine.
So, how to pass the current loop number together with the existing bunch of arguments all to the nested template?
My desired output would be:
Ape1 ate Apple1 and SH
Ape2 ate Apple2 and SH
. . .