Loop break


#1

I want to be able to exit a loop in a template/shortcode when a specific condition is fulfilled. For example, exit a range loop after locating the desired item. Using {{ break }} in the loop results in a function "break" not defined error.
I found Hugo discourse issue While - break-in Hugo, and the related golang issue #20531. This issue was resolved only recently, on 17 Oct 2017, by adding support for {{ break }} and {{ continue }} (done in golang commit 3be5d55). I’m using the latest 0.30.2 version of Hugo, which was released on 19 Oct 2017.
–> Will {{ break }} and {{ continue }} be supported in the next version of Hugo?


#2

It will be supported in the next version after the date Go 1.10 is released.


#3

Hi Bjorn. I see that [Hugo v0.37|https://github.com/gohugoio/hugo/releases/tag/v0.37] supports Go v1.10. So are the {{ break }} and {{ continue }} loop statements supported in Hugo v0.37+?

(Feel free to also point out additional advantages of Go 1.10 that we might be able to use to improve our Hugo development :-).)

Thanks.


#4

Those statements are not in Go 1.10 (was pulled out at the last minute).


#5

Very disappointing … . Do you know whether these statements planned to be added in a future Go release?


#6

I want this as well. It feels very limiting not being able to do this.