aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Powell <oliverpowell84@gmail.com>2019-10-05 13:05:56 +0200
committerRob Pike <r@golang.org>2019-12-17 11:10:58 +0000
commitba4593ac47f4eaa22bd61f5e44e80eea6f965768 (patch)
treeeeed3e9d5b73b8cc111a5dda2fcd2e08c24af465
parent001fe7f33f1d7aed9e3a047bd8e784bdc103c28c (diff)
downloadgo-ba4593ac47f4eaa22bd61f5e44e80eea6f965768.tar.gz
go-ba4593ac47f4eaa22bd61f5e44e80eea6f965768.zip
text/template: remove an incorrect comment and clarify docs for AddParseTree
The comment "If the name is the name of this template, overwrite this template." is incorrect and should be "is not" instead. This comment is no longer required once the docs are updated to mention this behaviour instead. Fixes #34695 Change-Id: I773495b2194d7bb7619b13c1a28cbc76e8f69aac Reviewed-on: https://go-review.googlesource.com/c/go/+/199139 Reviewed-by: Rob Pike <r@golang.org>
-rw-r--r--src/text/template/template.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/text/template/template.go b/src/text/template/template.go
index 2c5ff013e3..e0c096207c 100644
--- a/src/text/template/template.go
+++ b/src/text/template/template.go
@@ -119,12 +119,12 @@ func (t *Template) copy(c *common) *Template {
}
}
-// 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)