Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithBundler ¶
func WithBundler(cfg *esbuild.Config) application.Option
WithBundler returns an application.Option that uses the esbuild bundler. This is the recommended way to configure the frontend for library mode.
Example:
application.New(views,
frontend.WithBundler(&esbuild.Config{
Entry: "components/index.ts",
Include: []string{"components"},
}),
)
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is the frontend controller that handles component bundling and serving.
func (*Controller) Handle ¶
func (c *Controller) Handle(r *http.Request) application.Controller
Handle implements the Controller interface (required but not used for frontend).
func (*Controller) Setup ¶
func (c *Controller) Setup(app *application.App)
Setup is called when the controller is registered with the application. It builds the components and registers routes.
type Frontend ¶
type Frontend struct {
SourceDir string // Default: "components"
OutputDir string // Default: "views/static/scripts/gen"
DevMode bool // Enable HMR and file watching
// contains filtered or unexported fields
}
Frontend manages JavaScript component islands within HTMX-driven pages.
func (*Frontend) Build ¶
Build compiles all components in SourceDir to OutputDir. Requires a bundler configured via WithBundler. Safe for concurrent calls — serialized to prevent overlapping esbuild runs.
func (*Frontend) Controller ¶
func (f *Frontend) Controller() (string, *Controller)
Controller returns a named controller that integrates the frontend bundler with the application.
func (*Frontend) Render ¶
Render returns an island container for the named component. Props are JSON-serialized into data-props attribute.