Skip to content

text/template: add break and continue support #20531

Closed
@bep

Description

@bep
Contributor

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

Activity

changed the title [-]text/template: Add break and continue support[/-] [+]proposal: text/template: add break and continue support[/+] on May 31, 2017
added this to the Proposal milestone on May 31, 2017
odeke-em

odeke-em commented on May 31, 2017

@odeke-em
Member

/cc @rsc @robpike and other text/template folks.

rsc

rsc commented on Jun 5, 2017

@rsc
Contributor

It does seem a little reasonable. I wouldn't want labels (or goto), though. Thoughts, @robpike?

robpike

robpike commented on Jun 5, 2017

@robpike
Contributor

It does seem reasonable but low priority.

changed the title [-]proposal: text/template: add break and continue support[/-] [+]text/template: add break and continue support[/+] on Jun 12, 2017
modified the milestones: Go1.10, Proposal on Jun 12, 2017
rsc

rsc commented on Jun 12, 2017

@rsc
Contributor

CLs welcome for Go 1.10. Thanks.

gopherbot

gopherbot commented on Sep 27, 2017

@gopherbot
Contributor

Change https://golang.org/cl/66410 mentions this issue: text/template: add break, continue actions in ranges

gopherbot

gopherbot commented on Feb 5, 2018

@gopherbot
Contributor

Change https://golang.org/cl/92155 mentions this issue: text/template: revert CL 66410 "add break, continue actions in ranges"

17 remaining items

gopherbot

gopherbot commented on Dec 21, 2021

@gopherbot
Contributor

Change https://golang.org/cl/373915 mentions this issue: doc/go1.18: document {text,html}/template {break,continue} commands

modified the milestones: Unplanned, Go1.18 on Nov 3, 2022
locked and limited conversation to collaborators on Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @rsc@jimmyfrasche@bep@ianlancetaylor@ALTree

        Issue actions

          text/template: add break and continue support · Issue #20531 · golang/go