简体   繁体   English

go-gin中{{template“ base”}}和{{template“ base”。}}之间的区别

[英]Difference between {{template “base” }} and {{template “base” .}} in go-gin

What is the difference between {{template "base" }} and {{template "base" .}} ? {{template "base" }}{{template "base" .}}什么区别?

I use go-gin, both can run with no problem. 我使用go-gin,两者都可以正常运行。 I cannot find any description in the documentation about this. 我在文档中找不到关于此的任何描述。

From godoc text/template : godoc文本/模板中

{{template "name"}}
The template with the specified name is executed with nil data. 指定名称的模板将使用nil数据执行。

{{template "name" pipeline}}
The template with the specified name is executed with dot set to the value of the pipeline. 指定名称的模板在将点设置为管道值的情况下执行。

So {{template "base"}} calls the template base with no data in the context (globals are still available, of course), and {{template "base" .}} calls it with whatever data is in-scope at the point of the call. 因此, {{template "base"}}调用上下文中没有数据的模板base (当然,全局变量仍然可用),而{{template "base" .}}则使用范围内的任何数据调用它{{template "base" .}}通话点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM