join.go 478 B

12345678910111213141516171819
  1. package templ
  2. import (
  3. "context"
  4. "io"
  5. )
  6. // Join returns a single `templ.Component` that will render provided components in order.
  7. // If any of the components return an error the Join component will immediately return with the error.
  8. func Join(components ...Component) Component {
  9. return ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
  10. for _, c := range components {
  11. if err = c.Render(ctx, w); err != nil {
  12. return err
  13. }
  14. }
  15. return nil
  16. })
  17. }