Sorry, I understand the naming now "The returned template's name will
have the (base) name and (parsed) contents of the first file. ". It
indeed created the template with the name of first file. So this code
worked.
http://weekly.play.golang.org/p/xk0MDveOvn
But I had to use {define} in all the templates.
{{define "footer"}}... I am footer{{end}}
{{define "header"}}I am header ...{{end}}
{{template "header"}}
.. I am main ...
{{template "footer"}}
So, it appears {define} is mandatory., even with glob.
Another question
the below code works, but if I call,
err = t.ExecuteTemplate(os.Stdout, "root", nil)
it fails
panic: html/template internal error: template escaping out of sync
Does this mean, the user has to explicitly state where should the
template execution start? When is the name of template created with
"New" useful?
------------ pgm ----------
package main
import (
"os"
"html/template"
)
func main() {
t, err := template.New("root").ParseFiles("main.set", "footer.set",
"header.set")
if err != nil {
panic(err)
}
err = t.Execute(os.Stdout, nil)
err = t.ExecuteTemplate(os.Stdout, "main.set", nil)
if err != nil {
panic(err)