From ff27abc06afc5ebf9f423c9f260b00f81eaf8d84 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 8 Aug 2013 14:16:32 -0700 Subject: [PATCH] common: clone template during validation to avoid unnecessary children --- common/template.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/template.go b/common/template.go index df3360017..fd78ae9d5 100644 --- a/common/template.go +++ b/common/template.go @@ -50,7 +50,12 @@ func (t *Template) Process(s string, data interface{}) (string, error) { // Validate the template. func (t *Template) Validate(s string) error { - _, err := t.root.New(t.nextTemplateName()).Parse(s) + root, err := t.root.Clone() + if err != nil { + return err + } + + _, err = root.New("template").Parse(s) return err }