Skip to content

text/template: (also html/template?) document Execute can write to writer before returning an error  #7445

@sidnei

Description

@sidnei
What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. create a template with multiple sub-templates (if i got the terminology right)
2. .Execute() it with a writer

What is the expected output?
If .Execute() returns an error, the expectation is that no output is written.

What do you see instead?
Depending on how the template is constructed, .Execute() may cause some data to be
written before the error is returned. 

It should be documented that if you require no output to be written in the case of an
error, then you should necessarily write out to a temporary buffer and check the error
first, and then copy the buffer to it's final destination.

Please provide any additional information below.
http://play.golang.org/p/1JYAcgouZd

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions