all repos — gomponents @ 0b85f722038e0cc6cc7b66b7d0a704d845b614db

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
}