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