about summary refs log tree commit diff stats
path: root/gomponents.go
diff options
context:
space:
mode:
authorMarkus Wüstenberg2024-09-19 19:33:58 +0200
committerGitHub2024-09-19 19:33:58 +0200
commit69b0da41dff1813f3939cf4ea09fbbb2d06b7719 (patch)
tree5c2eb3befabf9d666691a20f65d79513c5821e11 /gomponents.go
parentc97605aca761985ac45adfe19365801ec2682657 (diff)
downloadgomponents-69b0da41dff1813f3939cf4ea09fbbb2d06b7719.tar.lz
gomponents-69b0da41dff1813f3939cf4ea09fbbb2d06b7719.tar.zst
gomponents-69b0da41dff1813f3939cf4ea09fbbb2d06b7719.zip
Drop support for Go 1.16 and Go 1.17 (#203)
Fixes #184
Diffstat (limited to 'gomponents.go')
-rw-r--r--gomponents.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/gomponents.go b/gomponents.go
index ffe8483..1a3b4ee 100644
--- a/gomponents.go
+++ b/gomponents.go
@@ -246,6 +246,15 @@ func Rawf(format string, a ...interface{}) Node {
 	})
 }
 
+// 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
+}
+
 type group struct {
 	children []Node
 }