Skip to content

Commit f682ca8

Browse files
committed
html/template: update the documentation of the package
Moved the rationale and workaround from template.Parse()'s documentation to the package documentation, provided the link of the issue for more information.
1 parent 08bd49a commit f682ca8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/html/template/doc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ functions.
7373
For these internal escaping functions, if an action pipeline evaluates to
7474
a nil interface value, it is treated as though it were an empty string.
7575
76+
HTML/CSS/JS comments make the injection context ambiguous, and so correct
77+
escaping can't be guaranteed. A possible workaround is using a template.HTML variable.
78+
For more information you can refer to this https://github.com/golang/go/issues/28628
79+
7680
Errors
7781
7882
See the documentation of ErrorCode for details.

src/html/template/template.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ func (t *Template) DefinedTemplates() string {
174174
// Named template definitions ({{define ...}} or {{block ...}} statements) in text
175175
// define additional templates associated with t and are removed from the
176176
// definition of t itself. Comments in the html format i.e <!-- comment -->
177-
// are stripped while parsing, this is because they make the injection context
178-
// ambiguous, and so correct escaping can't be guaranteed. A possible workaround
179-
// is using a template.HTML variable.
177+
// are stripped while parsing.
180178
//
181179
// Templates can be redefined in successive calls to Parse,
182180
// before the first use of Execute on t or any associated template.

0 commit comments

Comments
 (0)