package lazyturbo ¶
import "golazy.dev/lazyturbo"
Constants ¶
const StreamMIME ¶
const (
StreamMIME = "text/vnd.turbo-stream.html"
)
Functions ¶
func AcceptsStream ¶
AcceptsStream reports whether r advertises Turbo Stream response support.
func AcceptsStream(r *http.Request) bool
func Frame ¶
Frame renders _<id>_frame.html.tpl and wraps the result in a <turbo-frame>.
func Frame(ctx *lazyview.Context, id string, data any, opts ...FrameOption) (lazyview.Fragment, error)
func FrameID ¶
FrameID returns the Turbo frame id requested by r.
func FrameID(r *http.Request) string
func FrameTag ¶
FrameTag wraps body in a <turbo-frame> tag.
func FrameTag(id string, body string, opts ...FrameOption) (lazyview.Fragment, error)
func Helpers ¶
Helpers returns the template helpers provided by lazyturbo.
func Helpers() map[string]any
func IsFrameRequest ¶
IsFrameRequest reports whether r was issued for a Turbo Frame.
func IsFrameRequest(r *http.Request) bool
func IsPrefetch ¶
IsPrefetch reports whether r is a Turbo link prefetch request.
func IsPrefetch(r *http.Request) bool
func ValidateFrameID ¶
ValidateFrameID checks whether id is safe to use as both a DOM id and a frame partial name.
func ValidateFrameID(id string) error
Types ¶
type FrameOption ¶
FrameOption configures a rendered <turbo-frame> element.
type FrameOption struct {
// contains filtered or unexported fields
}
func Action ¶
Action sets data-turbo-action. Valid values are advance and replace.
func Action(action string) FrameOption
func Autoscroll ¶
Autoscroll sets the frame autoscroll boolean attribute.
func Autoscroll() FrameOption
func AutoscrollBehavior ¶
AutoscrollBehavior sets data-autoscroll-behavior. Valid values are auto and smooth.
func AutoscrollBehavior(behavior string) FrameOption
func AutoscrollBlock ¶
AutoscrollBlock sets data-autoscroll-block. Valid values are end, start, center, and nearest.
func AutoscrollBlock(block string) FrameOption
func Busy ¶
Busy sets the frame busy boolean attribute.
func Busy() FrameOption
func Complete ¶
Complete sets the frame complete boolean attribute.
func Complete() FrameOption
func Disabled ¶
Disabled sets the frame disabled boolean attribute.
func Disabled() FrameOption
func Loading ¶
Loading sets the frame loading attribute. Valid values are eager and lazy.
func Loading(loading string) FrameOption
func Recurse ¶
Recurse sets the frame recurse attribute.
func Recurse(frameID string) FrameOption
func Refresh ¶
Refresh sets the frame refresh attribute. Turbo currently defines morph.
func Refresh(refresh string) FrameOption
func RefreshMorph ¶
RefreshMorph sets refresh="morph".
func RefreshMorph() FrameOption
func Src ¶
Src sets the frame src attribute.
func Src(src string) FrameOption
func Target ¶
Target sets the frame target attribute.
func Target(target string) FrameOption
Package lazyturbo provides Hotwire Turbo helpers for controllers and views.
lazyapp installs the template helpers automatically, and lazycontroller uses the package to render Turbo Frame responses when a request includes a Turbo-Frame header. Direct use is appropriate for custom lazyview setups that want the same turbo_frame helper without the rest of lazyapp.