Skip to content

Commit 263db9b

Browse files
committed
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/+/179739 Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 2f387ac commit 263db9b

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/html/template/template.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,10 @@ func parseFiles(t *Template, filenames ...string) (*Template, error) {
440440
return t, nil
441441
}
442442

443-
// ParseGlob creates a new Template and parses the template definitions from the
444-
// files identified by the pattern, which must match at least one file. The
445-
// returned template will have the (base) name and (parsed) contents of the
443+
// ParseGlob creates a new Template and parses the template definitions from
444+
// the files identified by the pattern. The files are matched according to the
445+
// semantics of filepath.Match, and the pattern must match at least one file.
446+
// The returned template will have the (base) name and (parsed) contents of the
446447
// first file matched by the pattern. ParseGlob is equivalent to calling
447448
// ParseFiles with the list of files matched by the pattern.
448449
//
@@ -453,10 +454,10 @@ func ParseGlob(pattern string) (*Template, error) {
453454
}
454455

455456
// ParseGlob parses the template definitions in the files identified by the
456-
// pattern and associates the resulting templates with t. The pattern is
457-
// processed by filepath.Glob and must match at least one file. ParseGlob is
458-
// equivalent to calling t.ParseFiles with the list of files matched by the
459-
// pattern.
457+
// pattern and associates the resulting templates with t. The files are matched
458+
// according to the semantics of filepath.Match, and the pattern must match at
459+
// least one file. ParseGlob is equivalent to calling t.ParseFiles with the
460+
// list of files matched by the pattern.
460461
//
461462
// When parsing multiple files with the same name in different directories,
462463
// the last one mentioned will be the one that results.

src/text/template/helper.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ func parseFiles(t *Template, filenames ...string) (*Template, error) {
9191
return t, nil
9292
}
9393

94-
// ParseGlob creates a new Template and parses the template definitions from the
95-
// files identified by the pattern, which must match at least one file. The
96-
// returned template will have the (base) name and (parsed) contents of the
94+
// ParseGlob creates a new Template and parses the template definitions from
95+
// the files identified by the pattern. The files are matched according to the
96+
// semantics of filepath.Match, and the pattern must match at least one file.
97+
// The returned template will have the (base) name and (parsed) contents of the
9798
// first file matched by the pattern. ParseGlob is equivalent to calling
9899
// ParseFiles with the list of files matched by the pattern.
99100
//
@@ -104,10 +105,10 @@ func ParseGlob(pattern string) (*Template, error) {
104105
}
105106

106107
// ParseGlob parses the template definitions in the files identified by the
107-
// pattern and associates the resulting templates with t. The pattern is
108-
// processed by filepath.Glob and must match at least one file. ParseGlob is
109-
// equivalent to calling t.ParseFiles with the list of files matched by the
110-
// pattern.
108+
// pattern and associates the resulting templates with t. The files are matched
109+
// according to the semantics of filepath.Match, and the pattern must match at
110+
// least one file. ParseGlob is equivalent to calling t.ParseFiles with the
111+
// list of files matched by the pattern.
111112
//
112113
// When parsing multiple files with the same name in different directories,
113114
// the last one mentioned will be the one that results.

0 commit comments

Comments
 (0)