Documentation
¶
Overview ¶
Package interactions contains optional client-interaction template helpers.
The core go-partial package does not register these helpers automatically. Applications opt in with:
root.SetFunc(interactions.FuncMap())
Index ¶
- Constants
- func Async(runtime *partial.Runtime, value any, args ...any) template.HTML
- func FuncMap() template.FuncMap
- func On(runtime *partial.Runtime, value any, args ...any) template.HTML
- func Poll(runtime *partial.Runtime, value any, args ...any) template.HTML
- func Prefetch(runtime *partial.Runtime, value any, args ...any) template.HTML
- func Refresh(runtime *partial.Runtime, value any, args ...any) template.HTML
- func Render(kind connector.InteractionKind, value any, runtime *partial.Runtime, ...) template.HTML
- func Reveal(runtime *partial.Runtime, value any, args ...any) template.HTML
- func Stage(markup ...MarkupRenderer) partial.RenderStage
- func Stream(runtime *partial.Runtime, value any, args ...any) template.HTML
- type Data
- type Interaction
- func NewAsync(endpoint string) Interaction
- func NewOn(event string, endpoint string) Interaction
- func NewPoll(endpoint string) Interaction
- func NewPrefetch(endpoint string) Interaction
- func NewRefresh(endpoint string) Interaction
- func NewReveal(endpoint string) Interaction
- func NewStream(endpoint string) Interaction
- func (i Interaction) As(name string) Interaction
- func (i Interaction) ContractName() string
- func (i Interaction) Every(interval time.Duration) Interaction
- func (i Interaction) EveryString(interval string) Interaction
- func (i Interaction) From(source string) Interaction
- func (i Interaction) ID(id string) Interaction
- func (i Interaction) Interaction() connector.Interaction
- func (i Interaction) Option(key string, value any) Interaction
- func (i Interaction) Param(key string, value any) Interaction
- func (i Interaction) Placeholder(placeholder string) Interaction
- func (i Interaction) Swap(swap string) Interaction
- func (i Interaction) Target(target string) Interaction
- func (i Interaction) Trigger(trigger string) Interaction
- type MarkupRenderer
Constants ¶
const ( // SwapInnerHTML replaces the target element's inner HTML. SwapInnerHTML = string(connector.SwapInnerHTML) // SwapOuterHTML replaces the target element itself. SwapOuterHTML = string(connector.SwapOuterHTML) )
const RenderKindInteraction partial.RenderKind = "interaction"
RenderKindInteraction is the renderer kind used for interaction markup.
Variables ¶
This section is empty.
Functions ¶
func Async ¶
Async renders an async interaction. Pass either an endpoint string with optional key/value parameters or an Interaction configured in Go.
go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, endpoint string, params ...any) html/template.HTML go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, interaction github.com/donseba/go-partial/exp/interactions.Interaction) html/template.HTML
func On ¶
On renders an interaction that refreshes when a browser event is dispatched. Pass either an Interaction or an event name followed by an endpoint.
go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, event string, endpoint string, params ...any) html/template.HTML go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, interaction github.com/donseba/go-partial/exp/interactions.Interaction) html/template.HTML
func Poll ¶
Poll renders an interaction that refreshes on an interval. When an endpoint string is used, a single extra argument is treated as the interval.
go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, endpoint string, params ...any) html/template.HTML go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, interaction github.com/donseba/go-partial/exp/interactions.Interaction) html/template.HTML
func Prefetch ¶
Prefetch renders a non-visual prefetch hint.
go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, endpoint string, params ...any) html/template.HTML go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, interaction github.com/donseba/go-partial/exp/interactions.Interaction) html/template.HTML
func Refresh ¶
Refresh renders a control that explicitly refreshes a target.
go-doc:include go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, endpoint string, params ...any) html/template.HTML go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, interaction github.com/donseba/go-partial/exp/interactions.Interaction) html/template.HTML
func Reveal ¶
Reveal renders an interaction that loads when the element enters the viewport.
go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, endpoint string, params ...any) html/template.HTML go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, interaction github.com/donseba/go-partial/exp/interactions.Interaction) html/template.HTML
func Stage ¶
func Stage(markup ...MarkupRenderer) partial.RenderStage
Stage returns a partial render stage for interaction markup.
func Stream ¶
Stream renders an SSE-backed interaction placeholder.
go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, endpoint string, params ...any) html/template.HTML go-doc:sig func(runtime *github.com/donseba/go-partial.Runtime, interaction github.com/donseba/go-partial/exp/interactions.Interaction) html/template.HTML
Types ¶
type Data ¶
type Data struct {
Runtime *partial.Runtime
Interaction connector.Interaction
Attrs map[string]string
}
Data is the render payload for RenderKindInteraction.
type Interaction ¶
type Interaction struct {
// contains filtered or unexported fields
}
Interaction is an optional builder for connector-aware client interactions. Register values with partial.SetContract("interaction", ...).
func NewAsync ¶
func NewAsync(endpoint string) Interaction
NewAsync creates an async interaction contract value.
func NewOn ¶
func NewOn(event string, endpoint string) Interaction
NewOn creates an event-driven interaction contract value.
func NewPoll ¶
func NewPoll(endpoint string) Interaction
NewPoll creates a polling interaction contract value.
func NewPrefetch ¶
func NewPrefetch(endpoint string) Interaction
NewPrefetch creates a prefetch interaction contract value.
func NewRefresh ¶
func NewRefresh(endpoint string) Interaction
NewRefresh creates a refresh-control interaction contract value.
func NewReveal ¶
func NewReveal(endpoint string) Interaction
NewReveal creates a reveal interaction contract value.
func NewStream ¶
func NewStream(endpoint string) Interaction
NewStream creates an SSE-backed interaction contract value.
func (Interaction) As ¶
func (i Interaction) As(name string) Interaction
As sets the contract name for this interaction.
func (Interaction) ContractName ¶
func (i Interaction) ContractName() string
ContractName returns the contract name used when registering the interaction.
func (Interaction) Every ¶
func (i Interaction) Every(interval time.Duration) Interaction
Every sets the polling interval.
func (Interaction) EveryString ¶
func (i Interaction) EveryString(interval string) Interaction
EveryString sets the polling interval from a raw connector interval string.
func (Interaction) From ¶
func (i Interaction) From(source string) Interaction
From sets the event source option for event-driven interactions.
func (Interaction) ID ¶
func (i Interaction) ID(id string) Interaction
ID sets the element ID used by the rendered interaction.
func (Interaction) Interaction ¶
func (i Interaction) Interaction() connector.Interaction
Interaction returns the connector interaction represented by the builder.
func (Interaction) Option ¶
func (i Interaction) Option(key string, value any) Interaction
Option sets a connector option.
func (Interaction) Param ¶
func (i Interaction) Param(key string, value any) Interaction
Param sets a URL/path parameter used when resolving the endpoint.
func (Interaction) Placeholder ¶
func (i Interaction) Placeholder(placeholder string) Interaction
Placeholder sets the placeholder markup text rendered before content loads.
func (Interaction) Swap ¶
func (i Interaction) Swap(swap string) Interaction
Swap sets the connector swap strategy.
func (Interaction) Target ¶
func (i Interaction) Target(target string) Interaction
Target sets the client-side target selector.
func (Interaction) Trigger ¶
func (i Interaction) Trigger(trigger string) Interaction
Trigger sets the browser event or connector trigger.
type MarkupRenderer ¶
type MarkupRenderer func(runtime *partial.Runtime, interaction connector.Interaction, attrs map[string]string) (template.HTML, error)
MarkupRenderer renders connector interaction attributes into final HTML.
func DefaultMarkupRenderer ¶
func DefaultMarkupRenderer() MarkupRenderer
DefaultMarkupRenderer renders small, unstyled wrappers around connector attributes.