diff options
| author | Russ Cox <rsc@golang.org> | 2021-05-20 12:46:33 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2021-09-23 02:52:10 +0000 |
| commit | d0dd26a88c019d54f22463daae81e785f5867565 (patch) | |
| tree | 95803033c564f840d9778568f7a0dd8f81c07774 /src/html/template/exec_test.go | |
| parent | 93453233bd00cc641d2f959f1faf236e0094c2bf (diff) | |
| download | go-d0dd26a88c019d54f22463daae81e785f5867565.tar.xz | |
html/template, text/template: implement break and continue for range loops
Break and continue for range loops was accepted as a proposal in June 2017.
It was implemented in CL 66410 (Oct 2017)
but then rolled back in CL 92155 (Feb 2018)
because html/template changes had not been implemented.
This CL reimplements break and continue in text/template
and then adds support for them in html/template as well.
Fixes #20531.
Change-Id: I05330482a976f1c078b4b49c2287bd9031bb7616
Reviewed-on: https://go-review.googlesource.com/c/go/+/321491
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/html/template/exec_test.go')
| -rw-r--r-- | src/html/template/exec_test.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/html/template/exec_test.go b/src/html/template/exec_test.go index 888587335d..523340bac9 100644 --- a/src/html/template/exec_test.go +++ b/src/html/template/exec_test.go @@ -567,6 +567,8 @@ var execTests = []execTest{ {"range empty no else", "{{range .SIEmpty}}-{{.}}-{{end}}", "", tVal, true}, {"range []int else", "{{range .SI}}-{{.}}-{{else}}EMPTY{{end}}", "-3--4--5-", tVal, true}, {"range empty else", "{{range .SIEmpty}}-{{.}}-{{else}}EMPTY{{end}}", "EMPTY", tVal, true}, + {"range []int break else", "{{range .SI}}-{{.}}-{{break}}NOTREACHED{{else}}EMPTY{{end}}", "-3-", tVal, true}, + {"range []int continue else", "{{range .SI}}-{{.}}-{{continue}}NOTREACHED{{else}}EMPTY{{end}}", "-3--4--5-", tVal, true}, {"range []bool", "{{range .SB}}-{{.}}-{{end}}", "-true--false-", tVal, true}, {"range []int method", "{{range .SI | .MAdd .I}}-{{.}}-{{end}}", "-20--21--22-", tVal, true}, {"range map", "{{range .MSI}}-{{.}}-{{end}}", "-1--3--2-", tVal, true}, |
