]> Cypherpunks repositories - gostls13.git/commitdiff
text/template,html/template: state that Funcs must happen before parsing
authorRob Pike <r@golang.org>
Tue, 21 Mar 2017 03:18:02 +0000 (20:18 -0700)
committerRob Pike <r@golang.org>
Tue, 21 Mar 2017 04:07:35 +0000 (04:07 +0000)
Any method that affects the parse must happen before parsing.
This obvious point is clear, but it's not clear to some that the
set of defined functions affect the parse.

Fixes #18971

Change-Id: I8b7f8c8cf85b028c18e5ca3b9797de92ea910669
Reviewed-on: https://go-review.googlesource.com/38413
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/html/template/template.go
src/text/template/template.go

index b313a6b104aa160a745a970d0d803b5ffbf9b955..e1f179abc221ad9445903f187bc1a3629407ebee 100644 (file)
@@ -325,6 +325,7 @@ func (t *Template) Name() string {
 type FuncMap map[string]interface{}
 
 // Funcs adds the elements of the argument map to the template's function map.
+// It must be called before the template is parsed.
 // It panics if a value in the map is not a function with appropriate return
 // type. However, it is legal to overwrite elements of the map. The return
 // value is the template, so calls can be chained.
index b6fceb1795c2f52889f9b13983bd46be7598e625..ed1ef3cf8deb928a4406fd2b6ccdcb26f41e23e3 100644 (file)
@@ -159,6 +159,7 @@ func (t *Template) Delims(left, right string) *Template {
 }
 
 // Funcs adds the elements of the argument map to the template's function map.
+// It must be called before the template is parsed.
 // It panics if a value in the map is not a function with appropriate return
 // type or if the name cannot be used syntactically as a function in a template.
 // It is legal to overwrite elements of the map. The return value is the template,