简体   繁体   中英

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

What is the difference between {{template "base" }} and {{template "base" .}} ?

I use go-gin, both can run with no problem. I cannot find any description in the documentation about this.

From 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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