Home Difference between {{template "base" }} and {{template "base" .}} in go-gin
Reply: 1

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

seokgyu
1#
seokgyu Published in 2017-12-07 01:28:48Z

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.

hobbs
2#
hobbs Reply to 2017-12-07 03:00:15Z

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.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.394229 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO