mirror of
https://github.com/golang/go
synced 2024-11-19 21:04:43 -07:00
text/template,html/template: document that partial results may be written on error
Fixes #7445. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/94640043
This commit is contained in:
parent
a663e0a038
commit
431b96bdbe
@ -62,6 +62,9 @@ func (t *Template) escape() error {
|
|||||||
|
|
||||||
// Execute applies a parsed template to the specified data object,
|
// Execute applies a parsed template to the specified data object,
|
||||||
// writing the output to wr.
|
// 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.
|
// A template may be executed safely in parallel.
|
||||||
func (t *Template) Execute(wr io.Writer, data interface{}) error {
|
func (t *Template) Execute(wr io.Writer, data interface{}) error {
|
||||||
if err := t.escape(); err != nil {
|
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
|
// ExecuteTemplate applies the template associated with t that has the given
|
||||||
// name to the specified data object and writes the output to wr.
|
// 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.
|
// A template may be executed safely in parallel.
|
||||||
func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
|
func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
|
||||||
tmpl, err := t.lookupAndEscapeTemplate(name)
|
tmpl, err := t.lookupAndEscapeTemplate(name)
|
||||||
|
@ -108,6 +108,9 @@ func errRecover(errp *error) {
|
|||||||
|
|
||||||
// ExecuteTemplate applies the template associated with t that has the given name
|
// ExecuteTemplate applies the template associated with t that has the given name
|
||||||
// to the specified data object and writes the output to wr.
|
// 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.
|
// A template may be executed safely in parallel.
|
||||||
func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
|
func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
|
||||||
tmpl := t.tmpl[name]
|
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,
|
// Execute applies a parsed template to the specified data object,
|
||||||
// and writes the output to wr.
|
// 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.
|
// A template may be executed safely in parallel.
|
||||||
func (t *Template) Execute(wr io.Writer, data interface{}) (err error) {
|
func (t *Template) Execute(wr io.Writer, data interface{}) (err error) {
|
||||||
defer errRecover(&err)
|
defer errRecover(&err)
|
||||||
|
Loading…
Reference in New Issue
Block a user