You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When templates with the same name are parsed together, an error only occurs if all
templates are not empty:
http://play.golang.org/p/zCOU4ggrqe
Only the last test here pass on tip:
func TestRedefinition(t *testing.T) {
_, err := New("root").Parse(`{{define "t"}}{{end}}{{define "t"}}{{end}}`, "", "", make(map[string]*Tree), nil)
if err == nil {
t.Errorf("expected error")
}
_, err = New("root").Parse(`{{define "t"}}a{{end}}{{define "t"}}{{end}}`, "", "", make(map[string]*Tree), nil)
if err == nil {
t.Errorf("expected error")
}
_, err = New("root").Parse(`{{define "t"}}{{end}}{{define "t"}}b{{end}}`, "", "", make(map[string]*Tree), nil)
if err == nil {
t.Errorf("expected error")
}
_, err = New("root").Parse(`{{define "t"}}a{{end}}{{define "t"}}b{{end}}`, "", "", make(map[string]*Tree), nil)
if err == nil {
t.Errorf("expected error")
}
}
Is this expected?
The text was updated successfully, but these errors were encountered:
Seems like a deliberate choice to me. See "godoc -src text/template associate", which
specifically allows redefinition of empty templates, and ignores the definition of empty
templates.
I am going to downgrade this issue to not-Go1.1. The behavior doesn't cause any problems.
The text was updated successfully, but these errors were encountered: