Documentation
¶
Index ¶
- Variables
- func AllowBlocking(ctx context.Context) context.Context
- func Any(v any) templ.Component
- func Attributes(a []Attr) templ.Component
- func Call(ctx context.Context, action Action) context.CancelFunc
- func E(f func(context.Context) templ.Component) templ.Component
- func F(f Fragment) templ.Component
- func Go(f func(context.Context)) templ.Component
- func HashId(string string) string
- func Head[M any](b Beam[M], cast func(M) HeadData) templ.Component
- func If(beam Beam[bool]) templ.Component
- func Include() templ.Component
- func Inject[T any](key any, beam Beam[T]) templ.Component
- func InstanceEnd(ctx context.Context)
- func InstanceId(ctx context.Context) string
- func InstanceLoad(ctx context.Context, key any) any
- func InstanceRemove(ctx context.Context, key any) any
- func InstanceSave(ctx context.Context, key any, value any) any
- func RandId() string
- func Run(f func(context.Context)) templ.Component
- func Script() templ.Component
- func ScriptDisposable() templ.Component
- func ScriptPrivate() templ.Component
- func SessionEnd(ctx context.Context)
- func SessionExpire(ctx context.Context, d time.Duration)
- func SessionId(ctx context.Context) string
- func SessionLoad(ctx context.Context, key any) any
- func SessionRemove(ctx context.Context, key any) any
- func SessionSave(ctx context.Context, key any, value any) any
- func SetStatus(ctx context.Context, statusCode int)
- func Status(statusCode int) templ.Component
- func Style() templ.Component
- func StyleDisposable() templ.Component
- func StylePrivate() templ.Component
- func Sub[T any](beam Beam[T], render func(T) templ.Component) templ.Component
- func Text(value any) templ.Component
- func XCall[T any](ctx context.Context, action Action) (<-chan CallResult[T], context.CancelFunc)
- type ABlur
- type AChange
- type AClick
- type AData
- type ADataMap
- type ADyn
- type AFileHref
- type AFocus
- type AFocusIn
- type AFocusOut
- type AGotPointerCapture
- type AHook
- type AHref
- type AInput
- type AKeyDown
- type AKeyUp
- type ALostPointerCapture
- type AMap
- type AOne
- type APointerCancel
- type APointerDown
- type APointerEnter
- type APointerLeave
- type APointerMove
- type APointerOut
- type APointerOver
- type APointerUp
- type ARawFileHref
- type ARawHook
- type ARawSrc
- type ARawSubmit
- type ASrc
- type ASubmit
- type Action
- func ActionOnlyEmit(name string, arg any) []Action
- func ActionOnlyIndicate(indicator []Indicator, duration time.Duration) []Action
- func ActionOnlyLocationAssign(model any) []Action
- func ActionOnlyLocationReload() []Action
- func ActionOnlyLocationReplace(model any) []Action
- func ActionOnlyRawLocationAssign(url string) []Action
- func ActionOnlyScroll(selector string, smooth bool) []Action
- type ActionEmit
- type ActionIndicate
- type ActionLocationAssign
- type ActionLocationReload
- type ActionLocationReplace
- type ActionRawLocationAssign
- type ActionScroll
- type Active
- type App
- type Attr
- type AttrInit
- type Attrs
- type Beam
- type CSP
- type CallResult
- type ChangeEvent
- type Door
- type ESConf
- type ESOptions
- type FocusEvent
- type Fragment
- type HeadData
- type HrefActiveMatch
- type ImportCommon
- type ImportCommonExternal
- type ImportCommonHosted
- type ImportModule
- type ImportModuleBundle
- type ImportModuleBundleFS
- type ImportModuleBytes
- type ImportModuleExternal
- type ImportModuleHosted
- type ImportModuleRaw
- type ImportModuleRawBytes
- type ImportStyle
- type ImportStyleBytes
- type ImportStyleExternal
- type ImportStyleHosted
- type Indicator
- func IndicatorOnlyAttr(attr string, value string) []Indicator
- func IndicatorOnlyAttrQuery(query string, attr string, value string) []Indicator
- func IndicatorOnlyAttrQueryAll(query string, attr string, value string) []Indicator
- func IndicatorOnlyAttrQueryParent(query string, attr string, value string) []Indicator
- func IndicatorOnlyClass(class string) []Indicator
- func IndicatorOnlyClassQuery(query string, class string) []Indicator
- func IndicatorOnlyClassQueryAll(query string, class string) []Indicator
- func IndicatorOnlyClassQueryParent(query string, class string) []Indicator
- func IndicatorOnlyClassRemove(class string) []Indicator
- func IndicatorOnlyClassRemoveQuery(query string, class string) []Indicator
- func IndicatorOnlyClassRemoveQueryAll(query string, class string) []Indicator
- func IndicatorOnlyClassRemoveQueryParent(query string, class string) []Indicator
- func IndicatorOnlyContent(content string) []Indicator
- func IndicatorOnlyContentQuery(query string, content string) []Indicator
- func IndicatorOnlyContentQueryAll(query string, content string) []Indicator
- func IndicatorOnlyContentQueryParent(query string, content string) []Indicator
- type IndicatorAttr
- type IndicatorClass
- type IndicatorClassRemove
- type IndicatorContent
- type InputEvent
- type JSX
- type KeyboardEvent
- type Location
- type ModelRoute
- type ModelRouter
- type Page
- type PageRoute
- type PageRouter
- type ParsedForm
- type PathMatcher
- type PointerEvent
- type QueryMatcher
- func QueryMatcherIfPresent(params ...string) QueryMatcher
- func QueryMatcherIgnoreAll() QueryMatcher
- func QueryMatcherIgnoreSome(params ...string) QueryMatcher
- func QueryMatcherOnlyIfPresent(params ...string) []QueryMatcher
- func QueryMatcherOnlyIgnoreAll() []QueryMatcher
- func QueryMatcherOnlyIgnoreSome(params ...string) []QueryMatcher
- func QueryMatcherOnlySome(params ...string) []QueryMatcher
- func QueryMatcherSome(params ...string) QueryMatcher
- type R
- type RAfter
- type REvent
- type RForm
- type RHook
- type RModel
- type RPage
- type RRawForm
- type RRawHook
- type Route
- type RouteDir
- type RouteFS
- type RouteFile
- type Router
- type Scope
- type ScopeBlocking
- type ScopeConcurrent
- type ScopeDebounce
- type ScopeFrame
- type ScopeSerial
- type ScopeSet
- type Selector
- type SessionCallback
- type SourceBeam
- type SystemConf
- type Use
- func UseCSP(csp CSP) Use
- func UseESConf(conf ESConf) Use
- func UseErrorPage(page func(message string) templ.Component) Use
- func UseFallback(handler http.Handler) Use
- func UseLicense(cert string) Use
- func UseModel[M any](handler func(m ModelRouter[M], r RModel[M]) ModelRoute) Use
- func UsePage[M any](handler func(p PageRouter[M], r RPage[M]) PageRoute) Usedeprecated
- func UseRoute(r Route) Use
- func UseSessionCallback(callback SessionCallback) Use
- func UseSystemConf(conf SystemConf) Use
Constants ¶
This section is empty.
Variables ¶
var DocsFS embed.FS
DocsFS is the embedded documentation tree for internal purposes.
Functions ¶
func AllowBlocking ¶
AllowBlocking returns a context that suppresses warnings when used with blocking X* operations. Use with caution.
func Attributes ¶
func Call ¶
func Call(ctx context.Context, action Action) context.CancelFunc
Call dispatches an action to the client side. Returns a cancel function to abort the call (best-effort).
func E ¶
E evaluates the provided function at render time and returns the resulting templ.Component.
This is useful when rendering logic is complex or better expressed in plain Go code, rather than templ syntax. The function is called with the current render context.
Example:
@doors.E(func(ctx context.Context) templ.Component {
user, err := db.Get(id)
if err != nil {
return RenderError(err)
}
return RenderUser(user)
})
Parameters:
- f: a function that returns a templ.Component, given the current render context
Returns:
- A templ.Component produced by evaluating f during rendering
func F ¶
F renders a Fragment as a templ.Component.
This helper wraps a Fragment and returns a valid templ.Component, enabling Fragments to be used inside other templ components.
Example:
templ Demo() {
@doors.F(&Counter{})
}
func Go ¶
Go starts a goroutine at render time using a blocking-safe context tied to the component's lifecycle.
The goroutine runs only if the component is rendered. The context is canceled when the component is unmounted, allowing for proper cleanup. You must explicitly listen to ctx.Done() to stop work.
The context allows safe blocking operations, making it safe to use with X* operations (e.g., XUpdate, XRemove).
Example:
@doors.Go(func(ctx context.Context) {
for {
select {
case <-time.After(time.Second):
door.Update(ctx, currentTime())
case <-ctx.Done():
return
}
}
})
Parameters:
- f: a function to run in a goroutine, scoped to the component's render lifecycle
Returns:
- A non-visual templ.Component that starts the goroutine when rendered
func HashId ¶
HashId creates ID using provided string, hashbased. For the same string outputs the same result. Suitable for HTML attributes.
func Head ¶
Head renders both <title> and <meta> elements that update dynamically based on a Beam value.
It outputs HTML <title> and <meta> tags, and includes the necessary script bindings to ensure all metadata updates reactively when the Beam changes on the server.
Example:
@doors.Head(beam, func(p Path) HeadData {
return HeadData{
Title: "Product: " + p.Name,
Meta: map[string]string{
"description": "Buy " + p.Name + " at the best price",
"keywords": p.Name + ", product, buy",
"og:title": p.Name,
"og:description": "Check out this amazing product",
},
}
})
Parameters:
- b: a Beam providing the input value (usually page path Beam)
- cast: a function that maps the Beam value to a HeadData struct.
Returns:
- A templ.Component that renders title and meta elements with remote call scripts.
func Include ¶
Include returns a component that includes the framework's main client-side script and styles. This should be placed in the HTML head section and is required for the framework to function.
func Inject ¶
Inject creates a reactive component that injects Beam values into the context for child components.
It subscribes to the Beam and re-renders its children whenever the value changes, making the current value available to child components via Extract().
This enables passing reactive values down the component tree without explicit prop drilling.
Example:
@Inject("user", userBeam) {
@UserProfile() // Can use ctx.Value("user").(User) to get current user
}
func InstanceEnd ¶
InstanceEnd ends the current instance (tab/window) but keeps the session and other instances active.
func InstanceId ¶
InstanceId returns the unique ID of the current instance. Useful for logging, debugging, and tracking connections.
func InstanceLoad ¶
InstanceLoad gets a value from instance-scoped storage by key. Returns nil if absent. Callers must type-assert the result.
func InstanceRemove ¶
InstanceRemove deletes a key/value from instance-scoped storage. Returns the removed value or nil if absent.
func InstanceSave ¶
InstanceSave stores a key/value in instance-scoped storage, isolated to the current instance. Returns the previous value.
func RandId ¶
func RandId() string
RandId returns a cryptographically secure, URL-safe random ID. Suitable for sessions, instances, tokens, attributes. Case-sensitive.
func Script ¶
Script converts inline script content to an external resource. The JavaScript/TypeScript content is processed by esbuild and served as an external resource with a src attribute. This is the default mode - the resource is publicly accessible as a static asset.
The script content is automatically wrapped in an anonymous async function to support await and protect the global context. A special $d variable is provided to access frontend framework functions.
The content must be wrapped in <script> tags. TypeScript is supported by adding type="application/typescript" (or "text/typescript") attribute.
Example:
@Script() {
<script>
console.log("Hello from [not] inline script!");
// $... provides access to framework functions
// await is supported due to async wrapper
await $hook("hello","world");
</script>
}
Or with TypeScript:
@Script() {
<script type="application/typescript">
const message: string = "TypeScript works!";
console.log(message);
</script>
}
func ScriptDisposable ¶
ScriptDisposable converts inline script content to an external resource within the current context scope without caching. The script is processed on every render and served with a src attribute, but not exposed as a static resource. The script content is wrapped in an anonymous async function and provides the $d variable. The content must be wrapped in <script> tags.
func ScriptPrivate ¶
ScriptPrivate converts inline script content to an external resource that is served securely within the current context scope. The script is processed and served with a src attribute, but not exposed as a publicly accessible static asset. The script content is wrapped in an anonymous async function and provides the $d variable. The content must be wrapped in <script> tags.
func SessionEnd ¶
SessionEnd immediately ends the current session and all instances. Use during logout to close authorized pages and free server resources.
func SessionExpire ¶
SessionExpire sets the maximum lifetime of the current session.
func SessionId ¶
SessionId returns the unique ID of the current session. All instances in the same browser share this ID via a session cookie.
func SessionLoad ¶
SessionLoad gets a value from session-scoped storage by key. Returns nil if absent. Callers must type-assert the result.
func SessionRemove ¶
SessionRemove deletes a key/value from session-scoped storage. Returns the removed value or nil if absent.
func SessionSave ¶
SessionSave stores a key/value in session-scoped storage shared by all instances in the session. Returns the previous value under the key.
func SetStatus ¶
SetStatus sets an HTTP status code for the page. Makes effect only at initial page render
func Status ¶
Status is a templ.Component that sets the HTTP status code when rendered in a template (e.g. @doors.Status(404)). Makes effect only at initial page render.
func Style ¶
Style converts inline CSS content to an external resource. The CSS is minified and served as an external resource with an href attribute. This is the default mode - the resource is publicly accessible as a static asset.
The content must be wrapped in <style> tags.
Example:
@Style() {
<style>
.my-class {
color: blue;
font-size: 14px;
}
</style>
}
func StyleDisposable ¶
StyleDisposable converts inline CSS content to an external resource within the current context scope without caching. The CSS is processed on every render and served with an href attribute, but not exposed as a static resource. The content must be wrapped in <style> tags.
func StylePrivate ¶
StylePrivate converts inline CSS content to an external resource that is served securely within the current context scope. The CSS is processed and served with an href attribute, but not exposed as a publicly accessible static asset. The content must be wrapped in <style> tags.
func Sub ¶
Sub creates a reactive component that automatically updates when a Beam value changes.
It subscribes to the Beam and re-renders the inner content whenever the value changes. The render function is called with the current Beam value and must return a templ.Component.
This is the preferred way to bind Beam values into the DOM in a declarative and reactive manner.
Example:
templ display(value int) {
<span>{strconv.Itoa(value)}</span>
}
templ demo(beam Beam[int]) {
@doors.Sub(beam, func(v int) templ.Component {
return display(v)
})
}
Parameters:
- beam: the reactive Beam to observe
- render: a function that maps the current Beam value to a templ.Component
Returns:
- A templ.Component that updates reactively as the Beam value changes
func Text ¶
Text converts any value to a component with escaped string using default formats.
Example:
@Text("Hello <world>") // Output: Hello <world>
@Text(42) // Output: 42
@Text(user.Name) // Output: John
func XCall ¶
func XCall[T any](ctx context.Context, action Action) (<-chan CallResult[T], context.CancelFunc)
XCall dispatches an action to the client side and returns a result channel. The channel is closed without a value if the call is canceled. Cancellation is best-effort. Wait on the channel only in contexts where blocking is allowed (hooks, goroutines). The output value is unmarshaled into type T. For all actions, except ActionEmit, use json.RawMessage as T.
Types ¶
type ABlur ¶
type ABlur struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[FocusEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
ABlur prepares a blur event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AChange ¶
type AChange struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[ChangeEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[ChangeEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AChange prepares a change event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AClick ¶
type AClick struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AClick prepares a click event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type AData ¶
type AData struct {
// Name of the data entry to read via JavaScript with $data(name).
// Required.
Name string
// Value to expose to the client. Marshaled to JSON.
// Required.
Value any
}
AData exposes server-provided data to JavaScript via $data(name).
The Value is marshaled to JSON and made available for client-side access. This is useful for passing initial state, configuration, or constants directly into the client runtime.
type ADyn ¶
type ADyn interface {
Attr
// Value sets the attribute's value.
Value(ctx context.Context, value string)
// Enable adds or removes the attribute.
Enable(ctx context.Context, enable bool)
}
ADyn is a dynamic attribute that can be updated at runtime.
type AFileHref ¶
type AFileHref struct {
// If true, resource is available for download only once.
Once bool
// File name. Optional.
Name string
// File system path to serve.
Path string
}
AFileHref prepares the href attribute for a downloadable resource served privately from a file system path.
type AFocus ¶
type AFocus struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[FocusEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AFocus prepares a focus event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AFocusIn ¶
type AFocusIn struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[FocusEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AFocusIn prepares a focusin event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AFocusOut ¶
type AFocusOut struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[FocusEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AFocusOut prepares a focusout event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AGotPointerCapture ¶
type AGotPointerCapture struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AGotPointerCapture prepares a gotpointercapture event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
func (AGotPointerCapture) Attr ¶
func (c AGotPointerCapture) Attr() AttrInit
type AHook ¶
type AHook[T any] struct { // Name of the hook to call from JavaScript via $hook(name, ...). // Required. Name string // Defines how the hook is scheduled (e.g. blocking, debounce). // Optional. Scope []Scope // Visual indicators while the hook is running. // Optional. Indicator []Indicator // Backend handler for the hook. // Receives typed input (T, unmarshaled from JSON) through RHook, // and returns any output which will be marshaled to JSON. // Should return true when the hook is complete and can be removed. // Required. On func(ctx context.Context, r RHook[T]) (any, bool) }
AHook binds a backend handler to a named client-side hook, allowing JavaScript code to call Go functions via $hook(name, ...).
Input data is unmarshaled from JSON into type T. Output data is marshaled to JSON from any.
Generic parameters:
- T: input data type, sent from the client
type AHref ¶
type AHref struct {
// Target path model value. Required.
Model any
// Active link indicator configuration. Optional.
Active Active
// Stop event propagation (for dynamic links). Optional.
StopPropagation bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running
// (for dynamic links). Optional.
Indicator []Indicator
// Actions to run before the hook request (for dynamic links). Optional.
Before []Action
// Actions to run after the hook request (for dynamic links). Optional.
After []Action
// Actions to run on error (for dynamic links).
// Default (nil) triggers a location reload.
OnError []Action
}
AHref prepares the href attribute for internal navigation and configures dynamic link behavior.
type AInput ¶
type AInput struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[InputEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[InputEvent]) bool
// If true, does not include value in event
// Optional.
ExcludeValue bool
// Actions to run on error.
// Optional.
OnError []Action
}
type AKeyDown ¶
type AKeyDown struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Filters by event.key if provided.
// Optional.
Filter []string
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Backend event handler.
// Receives a typed REvent[KeyboardEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[KeyboardEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
// Actions to run before the hook request.
// Optional.
Before []Action
}
AKeyDown prepares a key down event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AKeyUp ¶
type AKeyUp struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Filters by event.key if provided.
// Optional.
Filter []string
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Backend event handler.
// Receives a typed REvent[KeyboardEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[KeyboardEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
// Actions to run before the hook request.
// Optional.
Before []Action
}
AKeyUp prepares a key up event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type ALostPointerCapture ¶
type ALostPointerCapture struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
ALostPointerCapture prepares a lostpointercapture event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
func (ALostPointerCapture) Attr ¶
func (c ALostPointerCapture) Attr() AttrInit
type APointerCancel ¶
type APointerCancel struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerCancel prepares a pointer cancel event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
func (APointerCancel) Attr ¶
func (c APointerCancel) Attr() AttrInit
type APointerDown ¶
type APointerDown struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerDown prepares a pointer down event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
func (APointerDown) Attr ¶
func (c APointerDown) Attr() AttrInit
type APointerEnter ¶
type APointerEnter struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerEnter prepares a pointer enter event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
func (APointerEnter) Attr ¶
func (c APointerEnter) Attr() AttrInit
type APointerLeave ¶
type APointerLeave struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerLeave prepares a pointer leave event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
func (APointerLeave) Attr ¶
func (c APointerLeave) Attr() AttrInit
type APointerMove ¶
type APointerMove struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerMove prepares a pointer move event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
func (APointerMove) Attr ¶
func (c APointerMove) Attr() AttrInit
type APointerOut ¶
type APointerOut struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerOut prepares a pointer out event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
func (APointerOut) Attr ¶
func (c APointerOut) Attr() AttrInit
type APointerOver ¶
type APointerOver struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerOver prepares a pointer over event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
func (APointerOver) Attr ¶
func (c APointerOver) Attr() AttrInit
type APointerUp ¶
type APointerUp struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, REvent[PointerEvent]) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerUp prepares a pointer up event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
func (APointerUp) Attr ¶
func (c APointerUp) Attr() AttrInit
type ARawFileHref ¶
type ARawFileHref struct {
// If true, resource is available for download only once.
Once bool
// File name. Optional.
Name string
// Handler for serving the resource request.
Handler func(w http.ResponseWriter, r *http.Request)
}
ARawFileHref prepares the href attribute for a downloadable resource served privately and directly through a custom handler.
func (ARawFileHref) Attr ¶
func (s ARawFileHref) Attr() AttrInit
type ARawHook ¶
type ARawHook struct {
// Name of the hook to call from JavaScript via $hook(name, ...).
// Required.
Name string
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Backend handler for the hook.
// Provides raw access via RRawHook (body reader, multipart parser).
// Should return true when the hook is complete and can be removed.
// Required.
On func(ctx context.Context, r RRawHook) bool
}
ARawHook binds a backend handler to a named client-side hook, allowing JavaScript code to call Go functions via $hook(name, ...).
Unlike AHook, ARawHook does not perform JSON unmarshaling or marshaling. Instead, it gives full access to the raw request body and multipart form data, useful for streaming, custom parsing, or file uploads.
type ARawSrc ¶
type ARawSrc struct {
// If true, resource is available for download only once.
Once bool
// File name. Optional.
Name string
// Handler for serving the resource request.
Handler func(w http.ResponseWriter, r *http.Request)
}
ARawSrc prepares the src attribute for a downloadable resource served directly and privately through a custom handler.
type ARawSubmit ¶
type ARawSubmit struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend form handler.
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RRawForm) bool
// Actions to run on error.
// Optional.
OnError []Action
}
ARawSubmit handles form submissions with raw multipart data, giving full control over uploads, streaming, and parsing.
func (ARawSubmit) Attr ¶
func (s ARawSubmit) Attr() AttrInit
type ASrc ¶
type ASrc struct {
// If true, resource is available for download only once.
Once bool
// File name. Optional.
Name string
// File system path to serve.
Path string
}
ASrc prepares the src attribute for a downloadable resource served privately from a file system path.
type ASubmit ¶
type ASubmit[T any] struct { // MaxMemory sets the maximum number of bytes to parse into memory. // It is passed to ParseMultipartForm. // Defaults to 8 MB if zero. MaxMemory int // Defines how the hook is scheduled (e.g. blocking, debounce). // Optional. Scope []Scope // Visual indicators while the hook is running. // Optional. Indicator []Indicator // Actions to run before the hook request. // Optional. Before []Action // Backend form handler. // Should return true when the hook is complete and can be removed. // Required. On func(context.Context, RForm[T]) bool // Actions to run on error. // Optional. OnError []Action }
ASubmit handles form submissions with decoded data of type T, which must be a struct annotated for go-playground/form.
type Action ¶
type Action interface {
// contains filtered or unexported methods
}
Action performs a client-side operation
func ActionOnlyEmit ¶
ActionOnlyEmit returns a single ActionEmit.
func ActionOnlyIndicate ¶
ActionOnlyIndicate returns a single ActionIndicate.
func ActionOnlyLocationAssign ¶
ActionOnlyLocationAssign returns a single ActionLocationAssign.
func ActionOnlyLocationReload ¶
func ActionOnlyLocationReload() []Action
ActionOnlyLocationReload returns a single ActionLocationReload.
func ActionOnlyLocationReplace ¶
ActionOnlyLocationReplace returns a single ActionLocationReplace.
func ActionOnlyRawLocationAssign ¶
ActionOnlyRawLocationAssign returns a single ActionLocationAssign.
func ActionOnlyScroll ¶
ActionOnlyScroll returns a single ActionScroll.
type ActionEmit ¶
ActionEmit invokes a client-side handler registered with $on(name: string, func: (arg: any, err?: Error) => any).
type ActionIndicate ¶
ActionIndicate applies indicators for a fixed duration.
type ActionLocationAssign ¶
type ActionLocationAssign struct {
Model any
}
ActionLocationAssign navigates to a model-derived URL.
type ActionLocationReload ¶
type ActionLocationReload struct{}
ActionLocationReload reloads the current page.
type ActionLocationReplace ¶
type ActionLocationReplace struct {
Model any
}
ActionLocationReplace replaces the current location with a model-derived URL.
type ActionRawLocationAssign ¶
type ActionRawLocationAssign struct {
URL string
}
ActionRawLocationAssign navigates to a specified URL
type ActionScroll ¶
ActionScroll scrolls to the first element matching Selector.
type Active ¶
type Active struct {
// Path match strategy
PathMatcher PathMatcher
// Query param match strategy, applied sequientially
QueryMatcher []QueryMatcher
// Indicators to apply when active
Indicator []Indicator
}
Active configures active link indication
type App ¶
type App[M any] interface { Render(SourceBeam[M]) templ.Component }
App defines a renderable app component, where Render() must output page HTML M - the path model type.
type Beam ¶
Beam represents a reactive value stream that can be read, subscribed to, or watched.
When used in a render cycle, it is guaranteed that a Door and all of its children will observe the exact same value for a given Beam. This ensures stable and predictable rendering behavior, even when multiple components depend on the same reactive source.
func NewBeam ¶
func NewBeam[T any, T2 comparable](source Beam[T], cast func(T) T2) Beam[T2]
NewBeam derives a new Beam[T2] from an existing Beam[T] by applying a transformation function.
The cast function maps values from the source beam to the derived beam. Updates are only propagated when the new value passes the default equality function with != comparison to the old value
Parameters:
- source: the source Beam[T] to derive from
- cast: a function that transforms values from type T to type T2
Returns:
- A new Beam[T2] that emits transformed values when they differ from the previous value
func NewBeamEqual ¶
func NewBeamEqual[T any, T2 any](source Beam[T], cast func(T) T2, equal func(new T2, old T2) bool) Beam[T2]
NewBeamEqual derives a new Beam[T2] from an existing Beam[T] using custom transformation and filtering.
The cast function transforms source values from type T to type T2. The equality function determines whether updated values should be propagated by comparing new and old values. If equality function is nil, every transformation will be propagated regardless of value equality.
Parameters:
- source: the source Beam[T] to derive from
- cast: a function to transform T → T2
- equality: a function to determine if transformed values should propagate (equal values ignored) or nil to always propagate
Returns:
- A new Beam[T2] that emits transformed values filtered by the equality function
type CallResult ¶
CallResult holds the outcome of an XCall. Either Ok is set with the result, or Err is non-nil.
type ChangeEvent ¶
type ChangeEvent = front.ChangeEvent
type Door ¶
Door represents a dynamic placeholder in the DOM tree that can be updated, replaced, or removed at runtime.
It is a fundamental building block of the framework, used to manage dynamic HTML content. All changes made to a Door are automatically synchronized with the frontend DOM.
A Door is itself a templ.Component and can be used directly in templates:
@door
// or
@door {
// initial HTML content
}
Doors start inactive and become active when rendered. Operations on inactive doors are stored virtually and applied when the door becomes active. If a door is removed or replaced, it becomes inactive again, but operations continue to update its virtual state for potential future rendering.
The context used when rendering a Door's content follows the Door's lifecycle. This allows you to safely use `ctx.Done()` inside background goroutines that depend on the Door's presence in the DOM.
Extended methods (prefixed with X) return a channel that can be used to track when operations complete. The channel receives nil on success or an error on failure, then closes. For inactive doors, the channel closes immediately without sending a value.
During a single render cycle, Doors and their children are guaranteed to observe consistent state (Beam), ensuring stable and predictable rendering.
type ESConf ¶
type ESConf = resources.BuildProfiles
type FocusEvent ¶
type FocusEvent = front.FocusEvent
type Fragment ¶
Fragment is a helper interface for defining composable, stateful, and code-interactive components.
A Fragment groups fields, methods, and rendering logic into a reusable unit. This is especially useful when a simple templ function is not sufficient — for example, when you need to manage internal state, expose multiple methods, or control updates from Go code.
Fragments implement the Render method and can be rendered using the F() helper.
A Fragment can be stored in a variable, rendered once, and later updated by calling custom methods. These methods typically encapsulate internal Door updates — such as a Refresh() function that re-renders part of the fragment's content manually.
By default, a Fragment is static — its output does not change after rendering. To enable dynamic behavior, use a root-level Door to support targeted updates.
Example:
type Counter struct {
door doors.Door
count int
}
func (c *Counter) Refresh(ctx context.Context) {
c.door.Update(ctx, c.display())
}
templ (c *Counter) Render() {
@c.door {
@c.display()
}
<button { doors.A(ctx, doors.AClick{
On: func(ctx context.Context, _ doors.REvent[doors.PointerEvent]) bool {
c.count++
c.Refresh(ctx)
return false
},
})... }>
Click Me!
</button>
}
templ (c *Counter) display() {
Clicked { fmt.Sprint(c.count) } time(s)!
}
type HrefActiveMatch ¶
type HrefActiveMatch int
const ( MatchFull HrefActiveMatch = iota MatchPath MatchStarts )
type ImportCommon ¶
type ImportCommon struct {
// File system path to the module.
// Required.
Path string
// Custom name.
// Optional.
Name string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportCommon imports a Common JS from the provided path
type ImportCommonExternal ¶
type ImportCommonExternal struct {
// External URL to the module.
// Required.
Src string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportCommonExternal imports an external Common JS and adds it to CSP.
type ImportCommonHosted ¶
type ImportCommonHosted struct {
// Full path to the hosted module (application root).
// Required.
Src string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportCommonHosted just generates script tag
type ImportModule ¶
type ImportModule struct {
// Import map specifier name.
// Optional.
Specifier string
// File system path to the module.
// Required.
Path string
// Build profile for esbuild options.
// Optional.
Profile string
// Load the module immediately via a script tag.
// Optional.
Load bool
// Custom name for the generated file.
// Optional.
Name string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportModule imports a JS/TS file, processes it with esbuild, and exposes it as an ES module.
type ImportModuleBundle ¶
type ImportModuleBundle struct {
// Import map specifier name.
// Optional.
Specifier string
// Entry point file for the bundle.
// Required.
Entry string
// Build profile for esbuild options.
// Optional.
Profile string
// Load the module immediately via a script tag.
// Optional.
Load bool
// Custom name for the generated file.
// Optional.
Name string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportModuleBundle bundles a JS entry with its deps into one file using esbuild.
type ImportModuleBundleFS ¶
type ImportModuleBundleFS struct {
// Unique cache key for this filesystem/bundle combination.
// Required.
CacheKey string
// Import map specifier name.
// Optional.
Specifier string
// File system to read from.
// Required.
FS fs.FS
// Entry point file within the filesystem.
// Required.
Entry string
// Build profile for esbuild options.
// Optional.
Profile string
// Load the module immediately via a script tag.
// Optional.
Load bool
// Custom name for the generated file.
// Optional.
Name string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportModuleBundleFS bundles a JS entry from an fs.FS using esbuild.
type ImportModuleBytes ¶
type ImportModuleBytes struct {
// Import map specifier name.
// Optional.
Specifier string
// Module source code.
// Required.
Content []byte
// Build profile for esbuild options.
// Optional.
Profile string
// Load the module immediately via a script tag.
// Optional.
Load bool
// Custom name for the generated file.
// Optional.
Name string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportModuleBytes imports JS/TS content from bytes, processes it with esbuild, and exposes it as an ES module. Deprecated: use ImportModule instead.
type ImportModuleExternal ¶
type ImportModuleExternal struct {
// Import map specifier name.
// Optional.
Specifier string
// Load the module immediately via a script tag.
// Optional.
Load bool
// External URL to the module.
// Required.
Src string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportModuleExternal registers an external JS module URL and adds it to CSP.
type ImportModuleHosted ¶
type ImportModuleHosted struct {
// Import map specifier name.
// Optional.
Specifier string
// Load the module immediately via a script tag.
// Optional.
Load bool
// Full path to the hosted module (application root).
// Required.
Src string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportModuleHosted registers a locally hosted JS module without processing.
type ImportModuleRaw ¶
type ImportModuleRaw struct {
// Import map specifier name.
// Optional.
Specifier string
// File system path to the module.
// Required.
Path string
// Load the module immediately via a script tag.
// Optional.
Load bool
// Custom name for the generated file.
// Optional.
Name string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportModuleRaw imports a JS file as-is without processing.
type ImportModuleRawBytes ¶
type ImportModuleRawBytes struct {
// Import map specifier name.
// Optional.
Specifier string
// Raw JavaScript content.
// Required.
Content []byte
// Load the module immediately via a script tag.
// Optional.
Load bool
// Custom name for the generated file.
// Required.
Name string
// Additional HTML attributes for the script tag.
// Optional.
Attrs templ.Attributes
}
ImportModuleRawBytes serves raw JS content from bytes without processing. Deprecated: use ImportModuleRaw instead.
type ImportStyle ¶
type ImportStyle struct {
// File system path to the CSS file.
// Required.
Path string
// Custom name for the generated file.
// Optional.
Name string
// Additional HTML attributes for the link tag.
// Optional.
Attrs templ.Attributes
}
ImportStyle processes a CSS file (e.g., minify) and links it.
type ImportStyleBytes ¶
type ImportStyleBytes struct {
// CSS source code.
// Required.
Content []byte
// Custom name for the generated file.
// Required.
Name string
// Additional HTML attributes for the link tag.
// Optional.
Attrs templ.Attributes
}
ImportStyleBytes processes CSS content from bytes (e.g., minify) and links it. Deprecated: use ImportStyle instead.
type ImportStyleExternal ¶
type ImportStyleExternal struct {
// External URL to the stylesheet.
// Required.
Href string
// Additional HTML attributes for the link tag.
// Optional.
Attrs templ.Attributes
}
ImportStyleExternal links a CSS stylesheet from an external URL and adds it to CSP.
type ImportStyleHosted ¶
type ImportStyleHosted struct {
// Path to the hosted stylesheet.
// Required.
Href string
// Additional HTML attributes for the link tag.
// Optional.
Attrs templ.Attributes
}
ImportStyleHosted links a locally hosted CSS file without processing.
type Indicator ¶
Indicator is a temporary DOM modification. It can change content, attributes, or classes, and is cleaned up automatically.
func IndicatorOnlyAttr ¶
IndicatorOnlyAttr sets an attribute on the event target element.
func IndicatorOnlyAttrQuery ¶
IndicatorOnlyAttrQuery sets an attribute on the first element matching a CSS query.
func IndicatorOnlyAttrQueryAll ¶
IndicatorOnlyAttrQueryAll sets an attribute on all elements matching a CSS query.
func IndicatorOnlyAttrQueryParent ¶
IndicatorOnlyAttrQueryParent sets an attribute on the closest ancestor matching a CSS query.
func IndicatorOnlyClass ¶
IndicatorOnlyClass adds classes to the event target element.
func IndicatorOnlyClassQuery ¶
IndicatorOnlyClassQuery adds classes to the first element matching a CSS query.
func IndicatorOnlyClassQueryAll ¶
IndicatorOnlyClassQueryAll adds classes to all elements matching a CSS query.
func IndicatorOnlyClassQueryParent ¶
IndicatorOnlyClassQueryParent adds classes to the closest ancestor matching a CSS query.
func IndicatorOnlyClassRemove ¶
IndicatorOnlyClassRemove removes classes from the event target element.
func IndicatorOnlyClassRemoveQuery ¶
IndicatorOnlyClassRemoveQuery removes classes from the first element matching a CSS query.
func IndicatorOnlyClassRemoveQueryAll ¶
IndicatorOnlyClassRemoveQueryAll removes classes from all elements matching a CSS query.
func IndicatorOnlyClassRemoveQueryParent ¶
IndicatorOnlyClassRemoveQueryParent removes classes from the closest ancestor matching a CSS query.
func IndicatorOnlyContent ¶
IndicatorOnlyContent sets content on the event target element.
func IndicatorOnlyContentQuery ¶
IndicatorOnlyContentQuery sets content on the first element matching a CSS query.
func IndicatorOnlyContentQueryAll ¶
IndicatorOnlyContentQueryAll sets content on all elements matching a CSS query.
func IndicatorOnlyContentQueryParent ¶
IndicatorOnlyContentQueryParent sets content on the closest ancestor matching a CSS query.
type IndicatorAttr ¶
type IndicatorAttr struct {
Selector Selector // Target element
Name string // Attribute name
Value string // Attribute value
}
IndicatorAttr temporarily sets an attribute on the selected element.
func (IndicatorAttr) Indicate ¶
func (c IndicatorAttr) Indicate() *indicate
type IndicatorClass ¶
type IndicatorClass struct {
Selector Selector // Target element
Class string // Space-separated classes
}
IndicatorClass temporarily adds CSS classes to the selected element.
func (IndicatorClass) Indicate ¶
func (c IndicatorClass) Indicate() *indicate
type IndicatorClassRemove ¶
type IndicatorClassRemove struct {
Selector Selector // Target element
Class string // Space-separated classes
}
IndicatorClassRemove temporarily removes CSS classes from the selected element.
func (IndicatorClassRemove) Indicate ¶
func (c IndicatorClassRemove) Indicate() *indicate
type IndicatorContent ¶
type IndicatorContent struct {
Selector Selector // Target element
Content string // Replacement content
}
IndicatorContent temporarily replaces innerHTML on the selected element.
func (IndicatorContent) Indicate ¶
func (c IndicatorContent) Indicate() *indicate
type InputEvent ¶
type InputEvent = front.InputEvent
type JSX ¶
type KeyboardEvent ¶
type KeyboardEvent = front.KeyboardEvent
type Location ¶
Location represents a URL built from a path model: path plus query. Use with navigation functions or href attributes.
type ModelRoute ¶
ModelRoute provides the response type for page handlers (page, redirect, reroute, or static content).
type ModelRouter ¶
type ModelRouter[M any] interface { // Page renders a Page. App(app App[M]) ModelRoute // PageFunc renders a Page from a function. AppFunc(AppFunc func(SourceBeam[M]) templ.Component) ModelRoute // StaticPage returns a static page with status. StaticPage(content templ.Component, status int) ModelRoute // Reroute performs an internal reroute to model (detached=true disables path sync). Reroute(model any, detached bool) ModelRoute // Redirect issues an HTTP redirect to model with status. Redirect(model any, status int) ModelRoute // Redirect issues an HTTP redirect to URL with status. RawRedirect(url string, status int) ModelRoute }
ModelRouter provides helpers to produce page responses.
type Page ¶
type Page[M any] interface { Render(SourceBeam[M]) templ.Component }
Page defines a renderable page component that the page must implement. M - the path model type. Deprecated: Use App[M]
type PageRoute ¶
type PageRoute = ModelRoute
PageRoute provides the response type for page handlers (page, redirect, reroute, or static content). Deprecated: Use ModelRoute
type PageRouter ¶
type PageRouter[M any] interface { // Page renders a Page. Page(page Page[M]) PageRoute // PageFunc renders a Page from a function. PageFunc(pageFunc func(SourceBeam[M]) templ.Component) PageRoute // StaticPage returns a static page with status. StaticPage(content templ.Component, status int) PageRoute // Reroute performs an internal reroute to model (detached=true disables path sync). Reroute(model any, detached bool) PageRoute // Redirect issues an HTTP redirect to model with status. Redirect(model any, status int) PageRoute // Redirect issues an HTTP redirect to URL with status. RawRedirect(url string, status int) PageRoute }
PageRouter provides helpers to produce page responses. Deprecated: Use ModelRouter[M any]
type ParsedForm ¶
type ParsedForm interface {
// FormValues returns all parsed form values.
FormValues() url.Values
// FormValue returns the first value for the given key.
FormValue(key string) string
// FormFile returns the uploaded file for the given key.
FormFile(key string) (multipart.File, *multipart.FileHeader, error)
// Form returns the underlying multipart.Form.
Form() *multipart.Form
}
ParsedForm exposes parsed form values and uploaded files.
type PathMatcher ¶
type PathMatcher interface {
// contains filtered or unexported methods
}
func PathMatcherFull ¶
func PathMatcherFull() PathMatcher
func PathMatcherParts ¶
func PathMatcherParts(i ...int) PathMatcher
PathMatcherParts checks if path parts by specified indexes matche
func PathMatcherStarts ¶
func PathMatcherStarts() PathMatcher
type PointerEvent ¶
type PointerEvent = front.PointerEvent
type QueryMatcher ¶
type QueryMatcher interface {
// contains filtered or unexported methods
}
func QueryMatcherIfPresent ¶
func QueryMatcherIfPresent(params ...string) QueryMatcher
QueryMatcherIfPresent matches the given parameters only if they are present.
func QueryMatcherIgnoreAll ¶
func QueryMatcherIgnoreAll() QueryMatcher
QueryMatcherIgnoreAll excludes all remaining query parameters from comparison.
func QueryMatcherIgnoreSome ¶
func QueryMatcherIgnoreSome(params ...string) QueryMatcher
QueryMatcherIgnoreSome excludes the given query parameters from comparison.
func QueryMatcherOnlyIfPresent ¶
func QueryMatcherOnlyIfPresent(params ...string) []QueryMatcher
QueryMatcherOnlyIfPresent matches the given parameters if present and ignores all others.
func QueryMatcherOnlyIgnoreAll ¶
func QueryMatcherOnlyIgnoreAll() []QueryMatcher
QueryMatcherOnlyIgnoreAll ignores all query parameters.
func QueryMatcherOnlyIgnoreSome ¶
func QueryMatcherOnlyIgnoreSome(params ...string) []QueryMatcher
QueryMatcherOnlyIgnoreSome ignores the given parameters and matches all remaining.
func QueryMatcherOnlySome ¶
func QueryMatcherOnlySome(params ...string) []QueryMatcher
QueryMatcherOnlySome matches the provided query parameters and ignores all others.
func QueryMatcherSome ¶
func QueryMatcherSome(params ...string) QueryMatcher
QueryMatcherSome matches only the provided query parameters.
type R ¶
type R interface {
// SetCookie adds a cookie to the response.
SetCookie(cookie *http.Cookie)
// GetCookie retrieves a cookie by name.
GetCookie(name string) (*http.Cookie, error)
// Done signals when the request context is canceled or completed.
Done() <-chan struct{}
}
R provides basic request operations including cookie management.
type RAfter ¶
type RAfter interface {
// After sets client-side actions to run once the request finishes.
After([]Action) error
}
RAfter allows setting client-side actions to run after a request completes.
type RModel ¶
type RModel[M any] interface { R // Model returns the decoded path model. Model() M // RequestHeader returns the incoming request headers. RequestHeader() http.Header // ResponseHeader returns the outgoing response headers. ResponseHeader() http.Header }
RModel provides request data and response control for model handlers.
type RPage ¶
RPage provides request data and response control for page handlers. Deprecated: Use RModel[M]
type RRawForm ¶
type RRawForm interface {
R
RAfter
// W returns the HTTP response writer.
W() http.ResponseWriter
// Reader returns a multipart reader for streaming form parts.
Reader() (*multipart.Reader, error)
// ParseForm parses the form data with a memory limit.
ParseForm(maxMemory int) (ParsedForm, error)
}
RRawForm provides access to raw multipart form data for streaming or custom parsing.
type RRawHook ¶
type RRawHook interface {
RRawForm
// Body returns the raw request body reader.
Body() io.ReadCloser
}
RRawHook provides access to raw request data for hook handlers without parsing.
type RouteDir ¶
type RouteDir struct {
// URL prefix under which files are served.
// Required.
Prefix string
// Filesystem directory path to serve.
// Required.
DirPath string
// Cache-Control header applied to responses.
// Optional.
CacheControl string
}
RouteDir serves files from a local directory under a URL prefix. The prefix must not be root ("/").
type RouteFS ¶
type RouteFS struct {
// URL prefix under which files are served.
// Required.
Prefix string
// Filesystem to serve files from.
// Required.
FS fs.FS
// Optional Cache-Control header applied to responses.
// Optional.
CacheControl string
}
RouteFS serves files from an fs.FS under a URL prefix. The prefix must not be root ("/").
type RouteFile ¶
type RouteFile struct {
// URL path at which the file is served.
// Required.
Path string
// Filesystem path to the file to serve.
// Reuired.
FilePath string
// Cache-Control header applied to the response.
// Optional.
CacheControl string
}
RouteFile serves a single file at a fixed URL path. The path must not be root ("/").
type Router ¶
Router represents the main HTTP router that handles all requests. It implements http.Handler and provides configuration through Use().
type Scope ¶
Scope controls concurrency for event processing. It defines how events are queued, blocked, debounced, or serialized.
func ScopeOnlyBlocking ¶
func ScopeOnlyBlocking() []Scope
ScopeOnlyBlocking creates a blocking scope that cancels concurrent events.
func ScopeOnlyDebounce ¶
ScopeOnlyDebounce creates a debounced scope with duration and limit.
func ScopeOnlySerial ¶
func ScopeOnlySerial() []Scope
ScopeOnlySerial creates a serial scope that executes events sequentially.
type ScopeBlocking ¶
type ScopeBlocking struct {
// contains filtered or unexported fields
}
ScopeBlocking cancels new events while one is processing. Useful for preventing double-clicks or duplicate submissions.
type ScopeConcurrent ¶
type ScopeConcurrent struct {
// contains filtered or unexported fields
}
ScopeConcurrent can be occupied by events with the same groupId, other - blocked
func (*ScopeConcurrent) Scope ¶
func (d *ScopeConcurrent) Scope(groupId int) Scope
type ScopeDebounce ¶
type ScopeDebounce struct {
// contains filtered or unexported fields
}
ScopeDebounce delays events by duration but guarantees execution within the specified limit. New events reset the delay.
type ScopeFrame ¶
type ScopeFrame struct {
// contains filtered or unexported fields
}
ScopeFrame distinguishes immediate and frame events. Immediate events run normally. Frame events wait for all prior events to finish, block new ones, then run exclusively.
func (*ScopeFrame) Scope ¶
func (d *ScopeFrame) Scope(frame bool) Scope
Scope creates a frame-based scope.
- frame=false: execute immediately
- frame=true: wait for completion of all events, then execute exclusively
type ScopeSerial ¶
type ScopeSerial struct {
// contains filtered or unexported fields
}
ScopeSerial queues events and processes them in order.
type Selector ¶
type Selector interface {
// contains filtered or unexported methods
}
Selector targets DOM elements for indicators. Select by event source, CSS query, or closest matching parent.
func SelectorParentQuery ¶
SelectorParentQuery selects the closest ancestor matching a CSS query.
func SelectorQuery ¶
SelectorQuery selects the first element matching a CSS query (e.g. "#id", ".class").
func SelectorQueryAll ¶
SelectorQuery selects all elements matching a CSS query (e.g. "#id", ".class").
func SelectorTarget ¶
func SelectorTarget() Selector
SelectorTarget selects the element that triggered the event.
type SessionCallback ¶
type SessionCallback = router.SessionCallback
type SourceBeam ¶
type SourceBeam[T any] = beam.SourceBeam[T]
SourceBeam is the initial Beam (others are derived from it), which, in addition to its core functionality, includes the ability to update values and propagate changes to all subscribers and derived beams. It serves as the root of a reactive value chain. Updates and mutations are synchronized across all subscribers, ensuring consistent state during rendering cycles. During a render cycle, all consumers will see a consistent view of the latest value. The source maintains a sequence of values for synchronization purposes.
IMPORTANT: For reference types (slices, maps, pointers, structs), do not modify the data directly. Instead, create or provide a different instance. Direct modification can break the consistency guarantees since subscribers may observe partial changes or inconsistent state.
func NewSourceBeam ¶
func NewSourceBeam[T comparable](init T) SourceBeam[T]
NewSourceBeam creates a new SourceBeam with the given initial value. Updates are only propagated when the new value passes the default distinct function with != comparison to the old value
Parameters:
- init: the initial value for the SourceBeam
Returns:
- A new SourceBeam[T] instance
func NewSourceBeamEqual ¶
func NewSourceBeamEqual[T any](init T, equal func(new T, old T) bool) SourceBeam[T]
NewSourceBeamEqual creates a new SourceBeam with a custom equality function.
The equality function receives new and old values and should return true if the new value is considered different and should be propagated to subscribers. If equality is nil, every update will be propagated regardless of value equality.
Parameters:
- init: the initial value for the SourceBeam
- equality: a function to determine if transformed values should propagate (equal values ignored) or nil to always propagate
Returns:
- A new SourceBeam[T] instance that uses the equality function for update filtering
type SystemConf ¶
type SystemConf = common.SystemConf
SystemConf contains system-wide configuration options for the framework.
type Use ¶
Use represents a router modification that can be used to configure routing behavior.
func UseCSP ¶
UseCSP configures Content Security Policy headers for enhanced security. This helps prevent XSS attacks and other security vulnerabilities.
func UseESConf ¶
UseESConf configures esbuild profiles for JavaScript/TypeScript processing. Different profiles can be used for development vs production builds.
func UseErrorPage ¶
UseErrorPage sets a custom error page component for handling internal errors. The component receives the error message as a parameter.
func UseFallback ¶
UseFallback sets a fallback handler for requests that don't match any routes. This is useful for integrating with other HTTP handlers or serving custom 404 pages.
func UseLicense ¶
UseLicense verifies and adds license certificate. License is required for commercial production use. You can purchase suitable license at https://doors.dev or via email sales@doors.dev
func UseModel ¶
func UseModel[M any](handler func(m ModelRouter[M], r RModel[M]) ModelRoute) Use
UseModel registers a model handler for a path model type M. The model defines path/query patterns via struct tags.
Example:
type BlogPath struct {
Home bool `path:"/"` // Match root path
Post bool `path:"/post/:ID"` // Match /post/123, capture ID
List bool `path:"/posts"` // Match /posts
ID int // Captured from :ID parameter
Tag *string `query:"tag"` // Query parameter ?tag=golang
}
func UseRoute ¶
UseRoute adds a custom Route to the router. A Route must implement:
- Match(*http.Request) bool: whether the route handles the request
- Serve(http.ResponseWriter, *http.Request): serve the matched request
func UseSessionCallback ¶
func UseSessionCallback(callback SessionCallback) Use
UseSessionCallback registers callbacks for session lifecycle events. The Create callback is called when a new session is created. The Delete callback is called when a session is removed.
func UseSystemConf ¶
func UseSystemConf(conf SystemConf) Use
UseSystemConf applies system-wide configuration including timeouts, limits, and other framework behavior settings.