Commit 263db9b6 authored by Andrew Gerrand's avatar Andrew Gerrand

html/template, text/template: document glob semantics

This change updates the doc comments of the various ParseGlob functions
and methods to state that they use the semantics of filepath.Match when
matching the file name pattern.

Fixes #30608

Change-Id: Iee4bdc0a2a2f8647d1f9a910e4d72a5de9204d11
Reviewed-on: https://go-review.googlesource.com/c/go/+/179739Reviewed-by: default avatarDmitri Shuralyov <dmitshur@golang.org>
parent 2f387ac1
...@@ -440,9 +440,10 @@ func parseFiles(t *Template, filenames ...string) (*Template, error) { ...@@ -440,9 +440,10 @@ func parseFiles(t *Template, filenames ...string) (*Template, error) {
return t, nil return t, nil
} }
// ParseGlob creates a new Template and parses the template definitions from the // ParseGlob creates a new Template and parses the template definitions from
// files identified by the pattern, which must match at least one file. The // the files identified by the pattern. The files are matched according to the
// returned template will have the (base) name and (parsed) contents of the // semantics of filepath.Match, and the pattern must match at least one file.
// The returned template will have the (base) name and (parsed) contents of the
// first file matched by the pattern. ParseGlob is equivalent to calling // first file matched by the pattern. ParseGlob is equivalent to calling
// ParseFiles with the list of files matched by the pattern. // ParseFiles with the list of files matched by the pattern.
// //
...@@ -453,10 +454,10 @@ func ParseGlob(pattern string) (*Template, error) { ...@@ -453,10 +454,10 @@ func ParseGlob(pattern string) (*Template, error) {
} }
// ParseGlob parses the template definitions in the files identified by the // ParseGlob parses the template definitions in the files identified by the
// pattern and associates the resulting templates with t. The pattern is // pattern and associates the resulting templates with t. The files are matched
// processed by filepath.Glob and must match at least one file. ParseGlob is // according to the semantics of filepath.Match, and the pattern must match at
// equivalent to calling t.ParseFiles with the list of files matched by the // least one file. ParseGlob is equivalent to calling t.ParseFiles with the
// pattern. // list of files matched by the pattern.
// //
// When parsing multiple files with the same name in different directories, // When parsing multiple files with the same name in different directories,
// the last one mentioned will be the one that results. // the last one mentioned will be the one that results.
......
...@@ -91,9 +91,10 @@ func parseFiles(t *Template, filenames ...string) (*Template, error) { ...@@ -91,9 +91,10 @@ func parseFiles(t *Template, filenames ...string) (*Template, error) {
return t, nil return t, nil
} }
// ParseGlob creates a new Template and parses the template definitions from the // ParseGlob creates a new Template and parses the template definitions from
// files identified by the pattern, which must match at least one file. The // the files identified by the pattern. The files are matched according to the
// returned template will have the (base) name and (parsed) contents of the // semantics of filepath.Match, and the pattern must match at least one file.
// The returned template will have the (base) name and (parsed) contents of the
// first file matched by the pattern. ParseGlob is equivalent to calling // first file matched by the pattern. ParseGlob is equivalent to calling
// ParseFiles with the list of files matched by the pattern. // ParseFiles with the list of files matched by the pattern.
// //
...@@ -104,10 +105,10 @@ func ParseGlob(pattern string) (*Template, error) { ...@@ -104,10 +105,10 @@ func ParseGlob(pattern string) (*Template, error) {
} }
// ParseGlob parses the template definitions in the files identified by the // ParseGlob parses the template definitions in the files identified by the
// pattern and associates the resulting templates with t. The pattern is // pattern and associates the resulting templates with t. The files are matched
// processed by filepath.Glob and must match at least one file. ParseGlob is // according to the semantics of filepath.Match, and the pattern must match at
// equivalent to calling t.ParseFiles with the list of files matched by the // least one file. ParseGlob is equivalent to calling t.ParseFiles with the
// pattern. // list of files matched by the pattern.
// //
// When parsing multiple files with the same name in different directories, // When parsing multiple files with the same name in different directories,
// the last one mentioned will be the one that results. // the last one mentioned will be the one that results.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment