diff options
author | cuiweixie <cuiweixie@gmail.com> | 2023-05-19 10:07:04 +0800 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-05-19 16:51:35 +0000 |
commit | 944911af5630bec413237b9aba010661a353953e (patch) | |
tree | 2ccabdcaafc5b023446447305bebf2760bafdbbb /src/html | |
parent | 24617a068c55d0ee7ef56d1b9fb951ee1e75f67d (diff) | |
download | go-944911af5630bec413237b9aba010661a353953e.tar.gz go-944911af5630bec413237b9aba010661a353953e.zip |
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>
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/template/error.go | 11 | ||||
-rw-r--r-- | src/html/template/escape.go | 2 |
2 files changed, 4 insertions, 9 deletions
diff --git a/src/html/template/error.go b/src/html/template/error.go index d7d6f5b3ab..a763924d4a 100644 --- a/src/html/template/error.go +++ b/src/html/template/error.go @@ -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 { diff --git a/src/html/template/escape.go b/src/html/template/escape.go index a62ef159f0..80d40feab6 100644 --- a/src/html/template/escape.go +++ b/src/html/template/escape.go @@ -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: |