runtime.go 575 B

123456789101112131415161718192021
  1. package runtime
  2. import (
  3. "context"
  4. "io"
  5. "github.com/a-h/templ"
  6. )
  7. // GeneratedComponentInput is used to avoid generated code needing to import the `context` and `io` packages.
  8. type GeneratedComponentInput struct {
  9. Context context.Context
  10. Writer io.Writer
  11. }
  12. // GeneratedTemplate is used to avoid generated code needing to import the `context` and `io` packages.
  13. func GeneratedTemplate(f func(GeneratedComponentInput) error) templ.Component {
  14. return templ.ComponentFunc(func(ctx context.Context, w io.Writer) error {
  15. return f(GeneratedComponentInput{ctx, w})
  16. })
  17. }