aboutsummaryrefslogtreecommitdiff
path: root/src/text/template/parse/parse.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2022-03-15 10:21:08 +1100
committerRob Pike <r@golang.org>2022-03-15 00:19:35 +0000
commit41a82aa9c36bffab2593d50aa55a462fef4e5bd4 (patch)
treed23d64317bddd4412f62a5d89c67cbb616f6bec9 /src/text/template/parse/parse.go
parent15728ce950eea43d6f1b9fb29819d006071e843a (diff)
downloadgo-41a82aa9c36bffab2593d50aa55a462fef4e5bd4.tar.xz
text/template/parse: allow space after continue or break
Trivial fix: We must skip space after either of these keywords before we expect a closing delimiter. Also delete the stutter-generating extra 'in' in the error message. (See what I did there?) Fixes #51670 Change-Id: If5415632c36eaac6699bdc0aa6ce18be956c9b53 Reviewed-on: https://go-review.googlesource.com/c/go/+/392615 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Trust: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/text/template/parse/parse.go')
-rw-r--r--src/text/template/parse/parse.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/text/template/parse/parse.go b/src/text/template/parse/parse.go
index b0cbe9dfc8..ce548b0886 100644
--- a/src/text/template/parse/parse.go
+++ b/src/text/template/parse/parse.go
@@ -415,8 +415,8 @@ func (t *Tree) action() (n Node) {
// {{break}}
// Break keyword is past.
func (t *Tree) breakControl(pos Pos, line int) Node {
- if token := t.next(); token.typ != itemRightDelim {
- t.unexpected(token, "in {{break}}")
+ if token := t.nextNonSpace(); token.typ != itemRightDelim {
+ t.unexpected(token, "{{break}}")
}
if t.rangeDepth == 0 {
t.errorf("{{break}} outside {{range}}")
@@ -428,8 +428,8 @@ func (t *Tree) breakControl(pos Pos, line int) Node {
// {{continue}}
// Continue keyword is past.
func (t *Tree) continueControl(pos Pos, line int) Node {
- if token := t.next(); token.typ != itemRightDelim {
- t.unexpected(token, "in {{continue}}")
+ if token := t.nextNonSpace(); token.typ != itemRightDelim {
+ t.unexpected(token, "{{continue}}")
}
if t.rangeDepth == 0 {
t.errorf("{{continue}} outside {{range}}")