diff options
author | Markus Wüstenberg | 2024-09-19 19:33:58 +0200 |
---|---|---|
committer | GitHub | 2024-09-19 19:33:58 +0200 |
commit | 69b0da41dff1813f3939cf4ea09fbbb2d06b7719 (patch) | |
tree | 5c2eb3befabf9d666691a20f65d79513c5821e11 /gomponents.go | |
parent | c97605aca761985ac45adfe19365801ec2682657 (diff) | |
download | gomponents-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.go | 9 |
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 } |