summaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/a-h/templ/runtime/runtime.go
blob: aaa4a2c488617c3d3a805f1eb4e8f28d91d6b9c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package runtime

import (
	"context"
	"io"

	"github.com/a-h/templ"
)

// GeneratedComponentInput is used to avoid generated code needing to import the `context` and `io` packages.
type GeneratedComponentInput struct {
	Context context.Context
	Writer  io.Writer
}

// GeneratedTemplate is used to avoid generated code needing to import the `context` and `io` packages.
func GeneratedTemplate(f func(GeneratedComponentInput) error) templ.Component {
	return templ.ComponentFunc(func(ctx context.Context, w io.Writer) error {
		return f(GeneratedComponentInput{ctx, w})
	})
}