]> Cypherpunks.ru repositories - gostls13.git/commitdiff
html/template: expose ErrJSTemplate
authorcuiweixie <cuiweixie@gmail.com>
Fri, 19 May 2023 02:07:04 +0000 (10:07 +0800)
committerGopher Robot <gobot@golang.org>
Fri, 19 May 2023 16:51:35 +0000 (16:51 +0000)
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>
api/next/59584.txt [new file with mode: 0644]
src/html/template/error.go
src/html/template/escape.go

diff --git a/api/next/59584.txt b/api/next/59584.txt
new file mode 100644 (file)
index 0000000..4d8036d
--- /dev/null
@@ -0,0 +1,2 @@
+pkg html/template, const ErrJSTemplate = 12 #59584
+pkg html/template, const ErrJSTemplate ErrorCode #59584
index d7d6f5b3ab589ea1e44f235ba7e2f2716906a8a4..a763924d4a932265be27276c6e6ca2eb626e8f0e 100644 (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 {
index a62ef159f0dcdb569e63189c70e4e231f1900142..80d40feab685c7fd4ff61705979cdfe4eeb49990 100644 (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: