break
Stops the innermost range iteration and bypasses any remaining iterations.
- Syntax
- break
This template code:
{{ $s := slice "foo" "bar" "baz" }}
{{ range $s }}
{{ if eq . "bar" }}
{{ break }}
{{ end }}
<p>{{ . }}</p>
{{ end }}Is rendered to:
<p>foo</p>See Go’s text/template documentation for more information.
Last updated:
September 11, 2026
:
content: Comply with function/method description guidance in style guide (76fa3fc9e)
Improve this page