diff options
| author | Rob Pike <r@golang.org> | 2015-06-23 13:05:25 +1000 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2015-06-23 03:18:52 +0000 |
| commit | f2662f2c938f2f9fd21067169b2aaec89f8d0e9f (patch) | |
| tree | 9fe00656b741150bc087aa2311864cdcd05c06ac /src | |
| parent | c8aea7b18f81b97653f1861ee3acf10b1c074747 (diff) | |
| download | go-f2662f2c938f2f9fd21067169b2aaec89f8d0e9f.tar.xz | |
text/template: explain better the semantics of ParseFiles
Documentation change only.
Fixes #11247.
Change-Id: Ib412de2d643292dbe42b56dee955bdb877aee81b
Reviewed-on: https://go-review.googlesource.com/11329
Reviewed-by: David Symonds <dsymonds@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/text/template/helper.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/text/template/helper.go b/src/text/template/helper.go index 3636fb54d6..07d432bd3b 100644 --- a/src/text/template/helper.go +++ b/src/text/template/helper.go @@ -26,8 +26,8 @@ func Must(t *Template, err error) *Template { } // ParseFiles creates a new Template and parses the template definitions from -// the named files. The returned template's name will have the (base) name and -// (parsed) contents of the first file. There must be at least one file. +// the named files. The returned template's name will have the base name and +// parsed contents of the first file. There must be at least one file. // If an error occurs, parsing stops and the returned *Template is nil. func ParseFiles(filenames ...string) (*Template, error) { return parseFiles(nil, filenames...) @@ -36,6 +36,11 @@ func ParseFiles(filenames ...string) (*Template, error) { // ParseFiles parses the named files and associates the resulting templates with // t. If an error occurs, parsing stops and the returned template is nil; // otherwise it is t. There must be at least one file. +// Since the templates created by ParseFiles are named by the base +// names of the argument files, t should usually have the name of one +// of the (base) names of the files. If it does not, depending on t's +// contents before calling ParseFiles, t.Execute may fail. In that +// case use t.ExecuteTemplate to execute a valid template. func (t *Template) ParseFiles(filenames ...string) (*Template, error) { return parseFiles(t, filenames...) } |
