gpt4 book ai didi

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

转载 作者:数据小太阳 更新时间:2023-10-29 03:12:29 29 4
gpt4 key购买 nike

{{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".}} 使用调用时范围内的任何数据调用它。

关于templates - {{template "base"}} 和 {{template "base".}} 在 go-gin 中的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47686178/

29 4 0