]> Cypherpunks repositories - gostls13.git/commitdiff
text/template,html/template: document that partial results may be written on error
authorRob Pike <r@golang.org>
Mon, 19 May 2014 21:29:45 +0000 (14:29 -0700)
committerRob Pike <r@golang.org>
Mon, 19 May 2014 21:29:45 +0000 (14:29 -0700)
Fixes #7445.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/94640043

src/pkg/html/template/template.go
src/pkg/text/template/exec.go

index 744f139ba4417bfdae5762055ea8f83092067b74..d389658979aa4c045fa7a291c999340dd9a2aad3 100644 (file)
@@ -62,6 +62,9 @@ func (t *Template) escape() error {
 
 // Execute applies a parsed template to the specified data object,
 // writing the output to wr.
+// If an error occurs executing the template or writing its output,
+// execution stops, but partial results may already have been written to
+// the output writer.
 // A template may be executed safely in parallel.
 func (t *Template) Execute(wr io.Writer, data interface{}) error {
        if err := t.escape(); err != nil {
@@ -72,6 +75,9 @@ func (t *Template) Execute(wr io.Writer, data interface{}) error {
 
 // ExecuteTemplate applies the template associated with t that has the given
 // name to the specified data object and writes the output to wr.
+// If an error occurs executing the template or writing its output,
+// execution stops, but partial results may already have been written to
+// the output writer.
 // A template may be executed safely in parallel.
 func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
        tmpl, err := t.lookupAndEscapeTemplate(name)
index 505509a08540724c474d10970593ee0b36abfeb1..2f323126453fdc1ad6e1b8f03135128b83584e99 100644 (file)
@@ -108,6 +108,9 @@ func errRecover(errp *error) {
 
 // ExecuteTemplate applies the template associated with t that has the given name
 // to the specified data object and writes the output to wr.
+// If an error occurs executing the template or writing its output,
+// execution stops, but partial results may already have been written to
+// the output writer.
 // A template may be executed safely in parallel.
 func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
        tmpl := t.tmpl[name]
@@ -119,6 +122,9 @@ func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{})
 
 // Execute applies a parsed template to the specified data object,
 // and writes the output to wr.
+// If an error occurs executing the template or writing its output,
+// execution stops, but partial results may already have been written to
+// the output writer.
 // A template may be executed safely in parallel.
 func (t *Template) Execute(wr io.Writer, data interface{}) (err error) {
        defer errRecover(&err)