【发布时间】:2019-12-31 04:10:30
【问题描述】:
如何将数组的索引传递给模板? 我知道我可以这样做来访问第一个元素:
{{ with index . 0 }}
但我需要这样做:
{{ template "mytemp" index . 0 }}
这似乎不起作用。我也试过这个没用:
{{ with index . 0 }}
{{ template "mytemp" . }}
{{ end }}
我似乎无法弄清楚如何实现这一点。
【问题讨论】:
标签: go go-templates