【发布时间】:2017-04-15 12:25:17
【问题描述】:
我有一个简单的例子,一个模板(text/templates) 包含另一个这样的
`index.html`
{{ template "image_row" . }}
`image_row.html`
{{ define "image_row" }}
To stuff here
{{ end }}
现在我想重用图像行模板。假设我想传递一个简单的数字,以便 image_row 模板根据这个数字构建行
我想要类似的东西(其中 5 是附加参数)
index.html
{{ template "image_row" . | 5 }}
在这种情况下我怎么能做到这一点?
【问题讨论】:
-
请澄清:您的问题是关于
text/template?因为text/tempate允许嵌套模板定义。
标签: go go-templates