fiber-blazor Skill
This skill provides information on how to interact with the Fiber-Blazor components in this project.
Key Concepts
- Form Binding: Look for
//blazor:bindon structs. These generate randomized tags for security and isolation. - Templ Components: Use
GetBindingOf[StructName]()to get a binder that helps generate IDs and Names for HTML elements. - HTMX Attributes: Use
blazor.Post(),blazor.Target(), etc., to build htmx attributes in Go/Templ. - Utility-First CSS: Tailwind CSS is integrated. You can use Tailwind classes directly in your
.templfiles for styling.
Fiber v3 Integration
This framework is built on top of Fiber v3. Use the following utilities for seamless integration:
blazor.InitRender(component, lang, title): Initializes the root layout. It returns afiber.Handlerthat renders the initial page.blazor.Static(app, prefix, rootDir): Configures static file serving (e.g., forhtmx.jsandtailwindcss.js).blazor.SetRenderer(componentFunc, transformFunc): Handles HTMX requests.transformFunctakes the randomized request struct (Binded[StructName]) and converts it to data.componentFuncrenders the data into a Templ component.
Common Tasks
- Add a new bindable struct: Add
//blazor:bindabove your struct definition. - Generate code: Run
flazorto sync everything. - Create a template: Use the binder in your
.templfile to bind inputs. - Handle requests: Use
blazor.SetRendererin your Fiber app to process the form data. - Serve Static Files: Use
blazor.Static(app, "/statics", "./statics")in yourmain.go.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.