I don't seem to be able to range over an iter.Seq in a template. 

error: executing "test" at <.>: range can't iterate over 0x5103c0

        resulter := func(yield func(int) bool) {
                for _, v := range []int{1, 2, 3} {
                        if !yield(v) {
                                return
                        }
                }
        }

        tpl := `{{ range $aa := . }}{{ $aa }} {{ end }}`

        tplParsed := template.Must(template.New("test").Parse(tpl))
        err := tplParsed.Execute(os.Stdout, resulter)
        if err != nil {
                fmt.Println(err)
        }

https://go.dev/play/p/f1mrGFnfiUa?v=gotip 

https://pkg.go.dev/text/template says:
    {{range pipeline}} T1 {{end}}
        The value of the pipeline must be an array, slice, map, or channel

...is an iter.Seq or iter.Seq2 not intended to be added there?

Thanks,
Rory

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/Zom1GtKuUqJeVwse%40campbell-lange.net.

Reply via email to