当在 with
或 range
内时,.
的范围会改变。如何访问调用范围?
最佳答案
{{with .Inner}}
Outer: {{$.OuterValue}}
Inner: {{.InnerValue}}
{{end}}
$
记录在 text/template文档:
When execution begins, $ is set to the data argument passed to Execute, that is, to the starting value of dot.
关于go - 在模板中,如何在 "with"或 "range"范围内访问外部范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14800204/