Recently, I noticed that Templates()
of html/template.Template
works differently from the one of text/template.Template
.
// go1.12
func main() {
t := template.New( "" )
println( len( t.Templates() ) )
}
The result of this code depends on whether you imported text/template
or html/template
. You'll notice that the text one prints 0 while the other prints 1. Becuase of this, I looked into the GoDoc and the html one's documentation said that Templates()
includes itself -- but no further explanation. And I thought there must be some reason why; why does it have to be different from each other?