go-gin 中 {{template "base" }} 和 {{template "base" .}} 的区别

Difference between {{template "base" }} and {{template "base" .}} in go-gin

{{template "base" }}{{template "base" .}}有什么区别?

我用 go-gin,两者都可以 运行 没问题。我在文档中找不到关于此的任何描述。

来自godoc text/template

{{template "name"}}
The template with the specified name is executed with nil data.

{{template "name" pipeline}}
The template with the specified name is executed with dot set to the value of the pipeline.

因此 {{template "base"}} 在上下文中没有数据的情况下调用模板 base(当然,全局变量仍然可用),并且 {{template "base" .}} 使用范围内的任何数据调用它在通话点。