diff options
Diffstat (limited to 'libgo/go/text/template/template.go')
-rw-r--r-- | libgo/go/text/template/template.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/libgo/go/text/template/template.go b/libgo/go/text/template/template.go index 1135d819b99..e0c096207c7 100644 --- a/libgo/go/text/template/template.go +++ b/libgo/go/text/template/template.go @@ -110,20 +110,21 @@ func (t *Template) Clone() (*Template, error) { // copy returns a shallow copy of t, with common set to the argument. func (t *Template) copy(c *common) *Template { - nt := New(t.name) - nt.Tree = t.Tree - nt.common = c - nt.leftDelim = t.leftDelim - nt.rightDelim = t.rightDelim - return nt + return &Template{ + name: t.name, + Tree: t.Tree, + common: c, + leftDelim: t.leftDelim, + rightDelim: t.rightDelim, + } } -// AddParseTree adds parse tree for template with given name and associates it with t. -// If the template does not already exist, it will create a new one. -// If the template does exist, it will be replaced. +// AddParseTree associates the argument parse tree with the template t, giving +// it the specified name. If the template has not been defined, this tree becomes +// its definition. If it has been defined and already has that name, the existing +// definition is replaced; otherwise a new template is created, defined, and returned. func (t *Template) AddParseTree(name string, tree *parse.Tree) (*Template, error) { t.init() - // If the name is the name of this template, overwrite this template. nt := t if name != t.name { nt = t.New(name) |