| 1 |
--- |
| 2 |
title: break |
| 3 |
description: Used with the range statement, stops the innermost iteration and bypasses all remaining iterations. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
aliases: [] |
| 9 |
returnType: |
| 10 |
signatures: [break] |
| 11 |
--- |
| 12 |
|
| 13 |
This template code: |
| 14 |
|
| 15 |
```go-html-template |
| 16 |
{{ $s := slice "foo" "bar" "baz" }} |
| 17 |
{{ range $s }} |
| 18 |
{{ if eq . "bar" }} |
| 19 |
{{ break }} |
| 20 |
{{ end }} |
| 21 |
<p>{{ . }}</p> |
| 22 |
{{ end }} |
| 23 |
``` |
| 24 |
|
| 25 |
Is rendered to: |
| 26 |
|
| 27 |
```html |
| 28 |
<p>foo</p> |
| 29 |
``` |
| 30 |
|
| 31 |
{{% include "/_common/functions/go-template/text-template.md" %}} |