Skip to content

text/template: add break and continue support #20531

Closed
@bep

Description

@bep

This is a repost of #20523 with, hopefully, a more clear description.

Go templates currently do not support the break nor the continue keyword -- which surprises people trying a construct similar to the one below.

{{ range $i, $e := .SomeSlice }}
  {{ if gt $i 2 }}
    {{ break }}
  {{ end }}
  {{ $e }}
{{ end }}

/cc @igramnet

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions