1
0
mirror of https://github.com/golang/go synced 2024-11-26 03:57:57 -07:00

html/template: expose ErrJSTemplate

Fixes #59584

Change-Id: Iabe61476c7457dfffbfe5d0b1fe904901a466c73
Reviewed-on: https://go-review.googlesource.com/c/go/+/496395
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
This commit is contained in:
cuiweixie 2023-05-19 10:07:04 +08:00 committed by Gopher Robot
parent 24617a068c
commit 944911af56
3 changed files with 6 additions and 9 deletions

2
api/next/59584.txt Normal file
View File

@ -0,0 +1,2 @@
pkg html/template, const ErrJSTemplate = 12 #59584
pkg html/template, const ErrJSTemplate ErrorCode #59584

View File

@ -215,18 +215,13 @@ const (
// disallowed. Avoid using "html" and "urlquery" entirely in new templates.
ErrPredefinedEscaper
// errJSTmplLit: "... appears in a JS template literal"
// ErrJSTemplate: "... appears in a JS template literal"
// Example:
// <script>var tmpl = `{{.Interp}`</script>
// <script>var tmpl = `{{.Interp}}`</script>
// Discussion:
// Package html/template does not support actions inside of JS template
// literals.
//
// TODO(rolandshoemaker): we cannot add this as an exported error in a minor
// release, since it is backwards incompatible with the other minor
// releases. As such we need to leave it unexported, and then we'll add it
// in the next major release.
errJSTmplLit
ErrJSTemplate
)
func (e *Error) Error() string {

View File

@ -233,7 +233,7 @@ func (e *escaper) escapeAction(c context, n *parse.ActionNode) context {
} else {
return context{
state: stateError,
err: errorf(errJSTmplLit, n, n.Line, "%s appears in a JS template literal", n),
err: errorf(ErrJSTemplate, n, n.Line, "%s appears in a JS template literal", n),
}
}
case stateJSRegexp: