all repos — gomponents @ 033f6ac3c36da0e95882d2e00b8cdd54468d3050

HTML components in pure Go

gomponents_generic.go (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
//go:build go1.18
// +build go1.18

package gomponents

// Map a slice of anything to a slice of Nodes.
func Map[T any](ts []T, cb func(T) Node) []Node {
	var nodes []Node
	for _, t := range ts {
		nodes = append(nodes, cb(t))
	}
	return nodes
}