Perhaps I'm missing something in the documentation but I think this shows something odd happening when the name in New() and the first filename in ParseFiles() do not match:
package main import ( "fmt" "html/template" "log" "os" ) // x.tpl contains just one line: hello func main() { // Works { tpl := template.New("x.tpl") tpl, err := tpl.ParseFiles("x.tpl") if err != nil { log.Fatal("parse ", err) } fmt.Println(tpl.DefinedTemplates()) err = tpl.Execute(os.Stdout, nil) if err != nil { log.Fatal("exec ", err) } } // Execute fails because template is "incomplete or empty" // The only difference is the name passed to New() "y" does NOT match // the file name passed to ParseFiles() "x.tpl" { tpl := template.New("y") tpl, err := tpl.ParseFiles("x.tpl") if err != nil { log.Fatal("parse ", err) } fmt.Println(tpl.DefinedTemplates()) err = tpl.Execute(os.Stdout, nil) if err != nil { log.Fatal("exec ", err) } } } > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.