a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
7.14k stars 236 forks source link

[question] go 1.22 iterators / rangefunc #822

Open netbrain opened 2 days ago

netbrain commented 2 days ago

Will the templ framework implement the new rangefuncs / iterators from go 1.22?

Not quite sure if it will add any value to the framework as I just recently picked up on using templ, but I guess it could make looping over stuff easier?

Like for instance creating your own multiple custom iterators on structs or custom slice types for different ways of listing out the data?

netbrain commented 2 days ago

Seems templ already supports the iter.Seq and iter.Seq2 as looping functions. But could not get it working with the type func(yield func(V) bool) :shrug:

joerdav commented 2 days ago

Yes, I wouldn't expect there to be any work for templ to do to support iterators. What you are referring to will be a bug if it is not working, can you provide a reproducible example please?