1
0
mirror of https://github.com/a-h/templ.git synced 2025-02-06 09:27:56 +00:00
templ/join.go
Arman 3c65b4309b
feat: templ.Join method renders multiple components into a single component (#929)
Co-authored-by: Adrian Hesketh <adrianhesketh@hushmail.com>
2024-09-30 11:58:38 +01:00

20 lines
478 B
Go

package templ
import (
"context"
"io"
)
// Join returns a single `templ.Component` that will render provided components in order.
// If any of the components return an error the Join component will immediately return with the error.
func Join(components ...Component) Component {
return ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
for _, c := range components {
if err = c.Render(ctx, w); err != nil {
return err
}
}
return nil
})
}