summaryrefslogtreecommitdiff
path: root/libgo/go/text/template/helper.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/text/template/helper.go')
-rw-r--r--libgo/go/text/template/helper.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/libgo/go/text/template/helper.go b/libgo/go/text/template/helper.go
index 3636fb54d69..787ca62e5f3 100644
--- a/libgo/go/text/template/helper.go
+++ b/libgo/go/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,7 +36,13 @@ 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) {
+ t.init()
return parseFiles(t, filenames...)
}
@@ -92,6 +98,7 @@ func ParseGlob(pattern string) (*Template, error) {
// equivalent to calling t.ParseFiles with the list of files matched by the
// pattern.
func (t *Template) ParseGlob(pattern string) (*Template, error) {
+ t.init()
return parseGlob(t, pattern)
}