Documentation ¶
Index ¶
- Constants
- Variables
- func AsBool(str string) bool
- func AsStr(v bool) string
- func AsValue[T any](v any) T
- func ContextWithHx(c *fiber.Ctx) *fiber.Ctx
- func HxBoosted(c *fiber.Ctx) bool
- func HxCurrentURL(c *fiber.Ctx) string
- func HxHistoryRestoreRequest(c *fiber.Ctx) bool
- func HxReSelect(c *fiber.Ctx, target string)
- func HxReSwap(c *fiber.Ctx, target string)
- func HxReTarget(c *fiber.Ctx, target string)
- func HxRedirect(c *fiber.Ctx, url string)
- func HxReplaceURL(c *fiber.Ctx, url string)
- func HxRequest(c *fiber.Ctx) bool
- func HxTriggers(c *fiber.Ctx, target string)
- func IntAsString(v int) string
- func Locals[V any](c *fiber.Ctx, key any, value ...V) V
- func New(config ...Config) fiber.Handler
- func NewCompFuncHandler(handler CompFunc, config ...Config) fiber.Handler
- func NewCompHandler(n Node, config ...Config) fiber.Handler
- func NewHxControllerHandler(ctrl Controller, config ...Config) fiber.Handler
- func Pluralize(s string) string
- func PtrValue[V any](v *V) V
- func RenderComp(c *fiber.Ctx, n Node, opt ...RenderOpt) error
- func RenderPartial(c *fiber.Ctx) bool
- func Slug(s string) string
- func Static() fs.FS
- func StopPolling(c *fiber.Ctx) error
- func ValuePtr[V any](v V) *V
- type BindFunc
- type ClassNames
- type CompFunc
- type Config
- type Controller
- type DefaultController
- func (c *DefaultController) BindBody(obj interface{}) error
- func (c *DefaultController) BindParams(obj interface{}) error
- func (c *DefaultController) BindQuery(obj interface{}) error
- func (c *DefaultController) BindValues(funcs ...BindFunc) error
- func (c *DefaultController) Context() context.Context
- func (c *DefaultController) Ctx() *fiber.Ctx
- func (c *DefaultController) Delete() error
- func (c *DefaultController) Error(err error) error
- func (c *DefaultController) Finalize() error
- func (c *DefaultController) Get() error
- func (c *DefaultController) Head() error
- func (c *DefaultController) Hx() Hx
- func (c *DefaultController) Init(ctx *fiber.Ctx) error
- func (c *DefaultController) Options() error
- func (c *DefaultController) Patch() error
- func (c *DefaultController) Path() string
- func (c *DefaultController) Post() error
- func (c *DefaultController) Prepare() error
- func (c *DefaultController) Put() error
- func (c *DefaultController) Reset()
- func (c *DefaultController) Trace() error
- func (c *DefaultController) Values(key any, value ...any) (val any)
- func (c *DefaultController) ValuesBool(key any, value ...any) (val bool)
- func (c *DefaultController) ValuesInt(key any, value ...any) (val int)
- func (c *DefaultController) ValuesString(key any, value ...any) (val string)
- type FilterFunc
- type HTML5Props
- type HXSwapStyle
- type Hx
- type HxClassName
- type HxEventType
- type HxExtType
- type HxRequestHeader
- type HxResponseHeader
- type HxResponseHeaders
- type HxSwapDirection
- type HxSwapScrolling
- type HxSwapScrollingMode
- type HxSwapTiming
- type HxSwapTimingMode
- type Node
- func A(children ...Node) Node
- func Abbr(children ...Node) Node
- func Accept(v string) Node
- func Action(v string) Node
- func Address(children ...Node) Node
- func Alt(v string) Node
- func Area(children ...Node) Node
- func Aria(name, v string) Node
- func Article(children ...Node) Node
- func As(v string) Node
- func Aside(children ...Node) Node
- func Async() Node
- func Attribute(name string, value ...string) Node
- func Audio(children ...Node) Node
- func AutoComplete(v string) Node
- func AutoFocus() Node
- func AutoPlay() Node
- func B(children ...Node) Node
- func Base(children ...Node) Node
- func BlockQuote(children ...Node) Node
- func Body(children ...Node) Node
- func Br(children ...Node) Node
- func Button(children ...Node) Node
- func Canvas(children ...Node) Node
- func Caption(children ...Node) Node
- func Charset(v string) Node
- func Checked() Node
- func Cite(children ...Node) Node
- func Class(v string) Node
- func ClipRule(v string) Node
- func Code(children ...Node) Node
- func Col(children ...Node) Node
- func ColGroup(children ...Node) Node
- func ColSpan(v string) Node
- func Cols(v string) Node
- func Comment(comment string) Node
- func Content(v string) Node
- func Controls() Node
- func CrossOrigin(v string) Node
- func D(v string) Node
- func DElement(children ...Node) Node
- func DataAttribute(name, v string) Node
- func DataElement(children ...Node) Node
- func DataList(children ...Node) Node
- func Dd(children ...Node) Node
- func Defer() Node
- func Details(children ...Node) Node
- func Dfn(children ...Node) Node
- func Dialog(children ...Node) Node
- func Disabled() Node
- func Div(children ...Node) Node
- func Dl(children ...Node) Node
- func Doctype(sibling Node) Node
- func Dt(children ...Node) Node
- func Em(children ...Node) Node
- func Embed(children ...Node) Node
- func EncType(v string) Node
- func FieldSet(children ...Node) Node
- func FigCaption(children ...Node) Node
- func Figure(children ...Node) Node
- func Fill(v string) Node
- func FillRule(v string) Node
- func Filter(f func(n Node) bool, children ...Node) []Node
- func Footer(children ...Node) Node
- func For(v string) Node
- func Form(children ...Node) Node
- func FormAttribute(v string) Node
- func FormElement(children ...Node) Node
- func Group(children ...Node) Node
- func H1(children ...Node) Node
- func H2(children ...Node) Node
- func H3(children ...Node) Node
- func H4(children ...Node) Node
- func H5(children ...Node) Node
- func H6(children ...Node) Node
- func HGroup(children ...Node) Node
- func HTML(children ...Node) Node
- func HTML5(props HTML5Props, body ...Node) Node
- func HandlebarsTemplate(v string) Node
- func Head(children ...Node) Node
- func Header(children ...Node) Node
- func Height(v string) Node
- func Hr(children ...Node) Node
- func Href(v string) Node
- func HxBoost(v bool) Node
- func HxConfirm(msg string) Node
- func HxDelete(url string) Node
- func HxDisable() Node
- func HxDisabledElt(target string) Node
- func HxEncoding(enc string) Node
- func HxExt(ext string) Node
- func HxGet(url string) Node
- func HxInclude(target string) Node
- func HxIndicator(target string) Node
- func HxOn(target string, js string) Node
- func HxPath(url string) Node
- func HxPost(url string) Node
- func HxPrompt(msg string) Node
- func HxPushUrl(v bool) Node
- func HxPut(url string) Node
- func HxSelect(target string) Node
- func HxSelectOob(target string) Node
- func HxSwap(target string) Node
- func HxSwapOob(target string) Node
- func HxTarget(target string) Node
- func HxTrigger(target string) Node
- func HxValidate(v bool) Node
- func HyperScript(v string) Node
- func I(children ...Node) Node
- func ID(v string) Node
- func IFrame(children ...Node) Node
- func If(condition bool, n Node) Node
- func Img(children ...Node) Node
- func Input(children ...Node) Node
- func Ins(children ...Node) Node
- func Integrity(v string) Node
- func Is(v string) Node
- func Kbd(children ...Node) Node
- func Label(children ...Node) Node
- func Lang(v string) Node
- func Legend(children ...Node) Node
- func Li(children ...Node) Node
- func Link(children ...Node) Node
- func Loading(v string) Node
- func Loop() Node
- func Main(children ...Node) Node
- func Map(f func(i int) Node, children ...Node) []Node
- func Mark(children ...Node) Node
- func Max(v string) Node
- func MaxLength(v string) Node
- func Meta(children ...Node) Node
- func Meter(children ...Node) Node
- func Method(v string) Node
- func Min(v string) Node
- func MinLength(v string) Node
- func Multiple() Node
- func MustacheTemplate(v string) Node
- func Muted() Node
- func Name(v string) Node
- func Nav(children ...Node) Node
- func NoScript(children ...Node) Node
- func NunjucksTemplate(v string) Node
- func Object(children ...Node) Node
- func Ol(children ...Node) Node
- func OnClick(v string) Node
- func OptGroup(children ...Node) Node
- func Option(children ...Node) Node
- func P(children ...Node) Node
- func Param(children ...Node) Node
- func Path(children ...Node) Node
- func Pattern(v string) Node
- func Picture(children ...Node) Node
- func Placeholder(v string) Node
- func PlaysInline() Node
- func Poster(v string) Node
- func Pre(children ...Node) Node
- func Preload(v string) Node
- func Progress(children ...Node) Node
- func Q(children ...Node) Node
- func Raw(t string) Node
- func Rawf(format string, a ...interface{}) Node
- func ReadOnly() Node
- func Reduce(f func(prev Node, next Node) Node, children ...Node) Node
- func Rel(v string) Node
- func Required() Node
- func Role(v string) Node
- func RowSpan(v string) Node
- func Rows(v string) Node
- func S(children ...Node) Node
- func SVG(children ...Node) Node
- func Samp(children ...Node) Node
- func Script(children ...Node) Node
- func Section(children ...Node) Node
- func Select(children ...Node) Node
- func Selected() Node
- func Slot(children ...Node) Node
- func Small(children ...Node) Node
- func Source(children ...Node) Node
- func Span(children ...Node) Node
- func Src(v string) Node
- func SrcSet(v string) Node
- func Step(v string) Node
- func Stroke(v string) Node
- func StrokeWidth(v string) Node
- func Strong(children ...Node) Node
- func StyleAttribute(v string) Node
- func StyleElement(children ...Node) Node
- func Sub(children ...Node) Node
- func Summary(children ...Node) Node
- func Sup(children ...Node) Node
- func TBody(children ...Node) Node
- func TFoot(children ...Node) Node
- func THead(children ...Node) Node
- func TabIndex(v string) Node
- func Table(children ...Node) Node
- func Target(v string) Node
- func Td(children ...Node) Node
- func Template(children ...Node) Node
- func Text(t string) Node
- func Textarea(children ...Node) Node
- func Textf(format string, a ...interface{}) Node
- func Th(children ...Node) Node
- func Time(children ...Node) Node
- func Title(children ...Node) Node
- func TitleAttribute(v string) Node
- func TitleElement(children ...Node) Node
- func Tr(children ...Node) Node
- func Track(children ...Node) Node
- func Type(v string) Node
- func U(children ...Node) Node
- func Ul(children ...Node) Node
- func Value(v string) Node
- func Var(children ...Node) Node
- func Video(children ...Node) Node
- func ViewBox(v string) Node
- func Wbr(children ...Node) Node
- func Width(v string) Node
- func XSLTTemplat(v string) Node
- type NodeFunc
- type NodeType
- type NodeTypeDescriptor
- type RangeLoop
- type RenderOpt
- type Swap
- func (s *Swap) FocusScroll(focusScroll bool) *Swap
- func (s *Swap) IgnoreTitle(ignoreTitle bool) *Swap
- func (s *Swap) Scroll(direction HxSwapDirection, target ...string) *Swap
- func (s *Swap) ScrollBottom(target ...string) *Swap
- func (s *Swap) ScrollTop(target ...string) *Swap
- func (s *Swap) Settle(swap ...time.Duration) *Swap
- func (s *Swap) Show(direction HxSwapDirection, target ...string) *Swap
- func (s *Swap) ShowBottom(target ...string) *Swap
- func (s *Swap) ShowTop(target ...string) *Swap
- func (s *Swap) String() string
- func (s *Swap) Style(style HXSwapStyle) *Swap
- func (s *Swap) Swap(swap ...time.Duration) *Swap
- func (s *Swap) Transition(transition bool) *Swap
- type UnimplementedController
Examples ¶
Constants ¶
const ( ElementType = NodeType(iota) AttributeType )
const (
// StatusStopPolling is a helper status code to stop polling.
StatusStopPolling = 286
)
Variables ¶
var ( HxDefaultSwapDuration = 0 * time.Millisecond HxDefaultSettleDelay = 20 * time.Millisecond )
var ConfigDefault = Config{ ErrorHandler: defaultErrorHandler, Filters: []FilterFunc{}, }
ConfigDefault is the default config.
Functions ¶
func AsBool ¶
AsBool is a helper function that returns a boolean value based on the provided string.
func AsStr ¶ added in v1.0.1
AsStr is a helper function that returns a string value based on the provided boolean.
func AsValue ¶ added in v1.2.3
AsValue is a helper function that returns a value based on the provided pointer.
func HxBoosted ¶ added in v1.2.4
func HxBoosted(c *fiber.Ctx) bool
HxBoosted returns true if the request is boosted.
func HxCurrentURL ¶ added in v1.2.4
func HxCurrentURL(c *fiber.Ctx) string
HxCurrentURL returns the current URL.
func HxHistoryRestoreRequest ¶ added in v1.2.4
func HxHistoryRestoreRequest(c *fiber.Ctx) bool
HxHistoryRestoreRequest returns true if the request is a history restore request.
func HxReSelect ¶ added in v1.2.4
func HxReSelect(c *fiber.Ctx, target string)
HxReSelect is a helper function to reselect the response.
func HxReSwap ¶ added in v1.2.4
func HxReSwap(c *fiber.Ctx, target string)
HxReSwap is a helper function to swap the response.
func HxReTarget ¶ added in v1.2.4
func HxReTarget(c *fiber.Ctx, target string)
HxReTarget is a helper function to retarget the response.
func HxRedirect ¶ added in v1.2.4
func HxRedirect(c *fiber.Ctx, url string)
HxRedirect is a helper function to redirect the client.
func HxReplaceURL ¶ added in v1.2.4
func HxReplaceURL(c *fiber.Ctx, url string)
HxReplaceURL is a helper function to replace the current URL.
func HxRequest ¶ added in v1.2.4
func HxRequest(c *fiber.Ctx) bool
HxRequest returns true if the request is an htmx request.
func HxTriggers ¶ added in v1.2.4
func HxTriggers(c *fiber.Ctx, target string)
HxTriggers is a helper function to trigger an event.
func IntAsString ¶ added in v1.0.16
IntAsString is a helper function that returns a string value based on the provided integer.
func NewCompFuncHandler ¶ added in v1.0.4
NewCompFuncHandler returns a new comp handler.
func NewCompHandler ¶ added in v1.0.1
NewCompHandler returns a new comp handler.
func NewHxControllerHandler ¶ added in v1.0.42
func NewHxControllerHandler(ctrl Controller, config ...Config) fiber.Handler
NewHxControllerHandler returns a new htmx controller handler. nolint:gocyclo
func Pluralize ¶ added in v1.2.0
Pluralize is a helper function that returns the plural form of the provided string.
func PtrValue ¶ added in v1.2.3
func PtrValue[V any](v *V) V
PtrValue is a helper function that returns the value of the provided pointer.
func RenderComp ¶ added in v1.2.4
RenderComp is a helper function to render a component.
func RenderPartial ¶ added in v1.2.4
func RenderPartial(c *fiber.Ctx) bool
RenderPartial returns true if the request is an htmx request.
func Slug ¶ added in v1.2.0
Slug is a helper function that returns a slugified version of the provided string.
func StopPolling ¶ added in v1.2.4
func StopPolling(c *fiber.Ctx) error
StopPolling is a helper function to stop polling.
Types ¶
type ClassNames ¶ added in v1.0.1
ClassNames represents a set of class names.
func Merge ¶ added in v1.0.28
func Merge(classNames ...ClassNames) ClassNames
Merge returns a new ClassNames object that is the result of merging the provided ClassNames objects.
func (ClassNames) Copy ¶ added in v1.2.4
func (c ClassNames) Copy(src ...ClassNames)
Copy is copying all class names from the src to dst.
func (ClassNames) Merge ¶ added in v1.0.4
func (c ClassNames) Merge(classNames ClassNames) ClassNames
Merge merges the provided class names into the class names.
func (ClassNames) Render ¶ added in v1.0.1
func (c ClassNames) Render(w io.Writer) error
Render writes the class names to the provided writer.
func (ClassNames) String ¶ added in v1.0.1
func (c ClassNames) String() string
String returns the string representation of the ClassNames.
func (ClassNames) Type ¶ added in v1.0.1
func (c ClassNames) Type() NodeType
Type returns the node type of the ClassNames.
type Config ¶
type Config struct { // Next defines a function to skip this middleware when returned true. Next func(c *fiber.Ctx) bool // Filters is a list of filters that filter the context. Filters []FilterFunc // ErrorHandler is executed when an error is returned from fiber.Handler. // // Optional. Default: DefaultErrorHandler ErrorHandler fiber.ErrorHandler }
Config ...
type Controller ¶ added in v1.0.42
type Controller interface { // Init is called when the controller is initialized. Init(ctx *fiber.Ctx) error // Prepare is called before the controller is executed. Prepare() error // Finalize is called after the controller is executed. Finalize() error // Get is called when the controller is executed with the GET method. Get() error // Post is called when the controller is executed with the POST method. Post() error // Put is called when the controller is executed with the PUT method. Put() error // Patch is called when the controller is executed with the PATCH method. Patch() error // Delete is called when the controller is executed with the DELETE method. Delete() error // Options is called when the controller is executed with the OPTIONS method. Options() error // Trace is called when the controller is executed with the TRACE method. Trace() error // Head is called when the controller is executed with the HEAD method. Head() error // Error is called when an error occurs. Error(err error) error // Ctx returns the fiber.Ctx. Ctx() *fiber.Ctx }
Controller is the interface for the htmx controller.
type DefaultController ¶ added in v1.1.43
type DefaultController struct {
// contains filtered or unexported fields
}
UnimplementedController is the default controller implementation.
func NewDefaultController ¶ added in v1.1.43
func NewDefaultController() *DefaultController
NewDefaultController returns a new default controller.
func (*DefaultController) BindBody ¶ added in v1.1.44
func (c *DefaultController) BindBody(obj interface{}) error
BindForm binds the form to the given struct.
func (*DefaultController) BindParams ¶ added in v1.1.44
func (c *DefaultController) BindParams(obj interface{}) error
BindParams binds the params to the given struct.
func (*DefaultController) BindQuery ¶ added in v1.1.44
func (c *DefaultController) BindQuery(obj interface{}) error
BindQuery binds the query to the given struct.
func (*DefaultController) BindValues ¶ added in v1.1.53
func (c *DefaultController) BindValues(funcs ...BindFunc) error
BindValues binds the values to the context.
func (*DefaultController) Context ¶ added in v1.2.1
func (c *DefaultController) Context() context.Context
Context returns the context.
func (*DefaultController) Ctx ¶ added in v1.1.49
func (c *DefaultController) Ctx() *fiber.Ctx
Ctx returns the fiber.Ctx.
func (*DefaultController) Delete ¶ added in v1.1.43
func (c *DefaultController) Delete() error
Delete is called when the controller is executed with the DELETE method.
func (*DefaultController) Error ¶ added in v1.1.43
func (c *DefaultController) Error(err error) error
Error is called when an error occurs.
func (*DefaultController) Finalize ¶ added in v1.1.43
func (c *DefaultController) Finalize() error
Finalize is called after the controller is executed.
func (*DefaultController) Get ¶ added in v1.1.43
func (c *DefaultController) Get() error
Get is called when the controller is executed with the GET method.
func (*DefaultController) Head ¶ added in v1.1.44
func (c *DefaultController) Head() error
Head is called when the controller is executed with the HEAD method.
func (*DefaultController) Hx ¶ added in v1.1.43
func (c *DefaultController) Hx() Hx
Hx is a helper function to get the htmx from the context.
func (*DefaultController) Init ¶ added in v1.1.43
func (c *DefaultController) Init(ctx *fiber.Ctx) error
Init is called when the controller is initialized.
func (*DefaultController) Options ¶ added in v1.1.43
func (c *DefaultController) Options() error
Options is called when the controller is executed with the OPTIONS method.
func (*DefaultController) Patch ¶ added in v1.1.43
func (c *DefaultController) Patch() error
Patch is called when the controller is executed with the PATCH method.
func (*DefaultController) Path ¶ added in v1.1.49
func (c *DefaultController) Path() string
Path is a helper function to get the path from the context.
func (*DefaultController) Post ¶ added in v1.1.43
func (c *DefaultController) Post() error
Post is called when the controller is executed with the POST method.
func (*DefaultController) Prepare ¶ added in v1.1.43
func (c *DefaultController) Prepare() error
Prepare is called before the controller is executed.
func (*DefaultController) Put ¶ added in v1.1.43
func (c *DefaultController) Put() error
Put is called when the controller is executed with the PUT method.
func (*DefaultController) Reset ¶ added in v1.2.0
func (c *DefaultController) Reset()
Reset resets the controller.
func (*DefaultController) Trace ¶ added in v1.1.43
func (c *DefaultController) Trace() error
Trace is called when the controller is executed with the TRACE method.
func (*DefaultController) Values ¶ added in v1.1.49
func (c *DefaultController) Values(key any, value ...any) (val any)
Values is a helper function to get the values from the context.
func (*DefaultController) ValuesBool ¶ added in v1.1.49
func (c *DefaultController) ValuesBool(key any, value ...any) (val bool)
ValuesBool is a helper function to get the values as a bool from the context.
func (*DefaultController) ValuesInt ¶ added in v1.1.49
func (c *DefaultController) ValuesInt(key any, value ...any) (val int)
ValuesInt is a helper function to get the values as an int from the context.
func (*DefaultController) ValuesString ¶ added in v1.1.49
func (c *DefaultController) ValuesString(key any, value ...any) (val string)
ValuesString is a helper function to get the values as a string from the context.
type FilterFunc ¶ added in v1.1.44
type FilterFunc func(c *fiber.Ctx) error
FilterFunc is a function that filters the context.
type HTML5Props ¶ added in v1.0.1
type HTML5Props struct { Title string // The title of the HTML document. Description string // The description of the HTML document. Language string // The language of the HTML document. Head []Node // The nodes to be included in the head section of the HTML document. Attributes []Node // The attributes to be included in the HTML document. }
HTML5Props represents the properties for an HTML5 document.
type HXSwapStyle ¶ added in v1.0.2
type HXSwapStyle string
HxSwapStyle ...
const ( HxSwapInnerHTML HXSwapStyle = "innerHTML" HxSwapOuterHTML HXSwapStyle = "outerHTML" HxSwapBeforeBegin HXSwapStyle = "beforebegin" HxSwapAfterBegin HXSwapStyle = "afterbegin" HxSwapBeforeEnd HXSwapStyle = "beforeend" HxSwapAfterEnd HXSwapStyle = "afterend" HxSwapDelete HXSwapStyle = "delete" HxSwapNone HXSwapStyle = "none" )
type Hx ¶
type Hx interface { // HxBoosted returns true if the request is boosted. HxBoosted() bool // HxCurrentURL returns the current URL. HxCurrentURL() string // HxHistoryRestoreRequest returns true if the request is a history restore request. HxHistoryRestoreRequest() bool // HxPrompt returns the prompt. HxPrompt() string // HxRequest returns true if the request is an htmx request. HxRequest() bool // HxTarget returns the target. HxTarget() string // HxTriggerName returns the trigger name. HxTriggerName() string // HxTrigger returns the trigger. HxTrigger() string // HxRenderPartial returns true if the request is an htmx request. RenderPartial() bool // Write writes a response. Write(data []byte) (n int, err error) // WriteHTML writes an HTML response. WriteHTML(html template.HTML) (n int, err error) // WriteJSON writes a JSON response. WriteJSON(data any) (n int, err error) // WriteString writes a string. WriteString(s string) (n int, err error) // RenderComp renders a component. RenderComp(n Node, opt ...RenderOpt) error // StopPolling stops polling. StopPolling() error // Redirect redirects the client. Redirect(url string) // ReplaceURL replaces the current URL. ReplaceURL(url string) // ReSwap ... ReSwap(target string) // ReTarget ... ReTarget(target string) // ReSelect ... ReSelect(target string) // Trigger ... Trigger(target string) }
Hx is an interface for htmx requests.
func HxFromContext ¶
func HxFromContext(c *fiber.Ctx) Hx
HxFromContext is a helper function to get the htmx from the context.
type HxClassName ¶ added in v1.0.1
type HxClassName string
HxClassName represents a class name for htmx elements.
const ( HxClassNameAdded HxClassName = "htmx-added" HxClassNameIndicator HxClassName = "htmx-indicator" HxClassNameRequest HxClassName = "htmx-request" HxClassNameSettling HxClassName = "htmx-settling" HxClassNameSwapping HxClassName = "htmx-swapping" )
func (HxClassName) String ¶ added in v1.0.1
func (c HxClassName) String() string
String returns the string representation of the HxClassName.
type HxEventType ¶ added in v1.0.1
type HxEventType string
HxEventType represents the type of htmx event.
const ( HxEventTypeAbort HxEventType = "htmx:abort" HxEventTypeAfterLoad HxEventType = "htmx:afterLoad" HxEventTypeAfterProcessNode HxEventType = "htmx:afterProcessNode" HxEventTypeAfterRequest HxEventType = "htmx:afterRequest" )
List of predefined htmx event types.
func (HxEventType) String ¶ added in v1.0.1
func (e HxEventType) String() string
String returns the string representation of the HxEventType.
type HxExtType ¶ added in v1.0.33
type HxExtType string
HxExtType is a type for htmx extension types.
const ( HxExtClassTools HxExtType = "class-tools" // The class-tools extension allows you to add and remove classes from elements. HxExtClientSideTemplates HxExtType = "client-side-templates" // The client-side-templates extension allows you to use client-side templates to render the response. HxExtIgnoreDebug HxExtType = "ignore:debug" // The ignore:debug extension allows you to ignore the debug header. HxExtJSON HxExtType = "json-enc" // The json-enc extension allows you to specify the JSON encoding for the response. HxExtMultiSwap HxExtType = "multi-swap" // The multi-swap extension allows you to swap multiple elements in a single response. HxExtPathDeps HxExtType = "path-deps" // The path-deps extension allows you to specify the dependencies for a path. )
type HxRequestHeader ¶
type HxRequestHeader string
HxRequestHeader is a helper type for htmx request headers.
const ( HxRequestHeaderBoosted HxRequestHeader = "HX-Boosted" HxRequestHeaderCurrentURL HxRequestHeader = "HX-Current-URL" HxRequestHeaderHistoryRestoreRequest HxRequestHeader = "HX-History-Restore-Request" HxRequestHeaderPrompt HxRequestHeader = "HX-Prompt" HxRequestHeaderRequest HxRequestHeader = "HX-Request" HxRequestHeaderTarget HxRequestHeader = "HX-Target" HxRequestHeaderTrigger HxRequestHeader = "HX-Trigger" HxRequestHeaderTriggerName HxRequestHeader = "HX-Trigger-Name" )
func (HxRequestHeader) String ¶
func (h HxRequestHeader) String() string
String returns the header as a string.
type HxResponseHeader ¶
type HxResponseHeader string
HxResponseHeader ...
const ( HXLocation HxResponseHeader = "HX-Location" // Allows you to do a client-side redirect that does not do a full page reload HXPushUrl HxResponseHeader = "HX-Push-Url" // pushes a new url into the history stack HXRedirect HxResponseHeader = "HX-Redirect" // can be used to do a client-side redirect to a new location HXRefresh HxResponseHeader = "HX-Refresh" // if set to "true" the client side will do a full refresh of the page HXReplaceUrl HxResponseHeader = "HX-Replace-Url" // replaces the current URL in the location bar HXReswap HxResponseHeader = "HX-Reswap" // Allows you to specify how the response will be swapped. See hx-swap for possible values HXRetarget HxResponseHeader = "HX-Retarget" // A CSS selector that updates the target of the content update to a different element on the page HXReselect HxResponseHeader = "HX-Reselect" // A CSS selector that allows you to choose which part of the response is used to be swapped in. Overrides an existing hx-select on the triggering element HXTrigger HxResponseHeader = "HX-Trigger" // allows you to trigger client side events, see the documentation for more info HXTriggerAfterSettle HxResponseHeader = "HX-Trigger-After-Settle" // allows you to trigger client side events, see the documentation for more info HXTriggerAfterSwap HxResponseHeader = "HX-Trigger-After-Swap" // allows you to trigger client side events, see the documentation for more info )
func (HxResponseHeader) String ¶
func (h HxResponseHeader) String() string
String returns the header as a string.
type HxResponseHeaders ¶
type HxResponseHeaders struct {
// contains filtered or unexported fields
}
HxResponseHeaders ...
func (*HxResponseHeaders) Get ¶
func (h *HxResponseHeaders) Get(k HxResponseHeader) string
Get is a helper function to get a header.
func (*HxResponseHeaders) Set ¶
func (h *HxResponseHeaders) Set(k HxResponseHeader, val string)
Set is a helper function to set a header.
type HxSwapDirection ¶ added in v1.0.2
type HxSwapDirection string
HxSwapDirection ...
const ( HxSwapDirectionTop HxSwapDirection = "top" HxSwapDirectionBottom HxSwapDirection = "bottom" )
type HxSwapScrolling ¶ added in v1.0.2
type HxSwapScrolling struct {
// contains filtered or unexported fields
}
HxSwapScrolling ...
func (*HxSwapScrolling) String ¶ added in v1.0.2
func (s *HxSwapScrolling) String() string
String ...
type HxSwapScrollingMode ¶ added in v1.0.2
type HxSwapScrollingMode string
HxSwapScrollingMode ...
const ( HxSwapScrollingScroll HxSwapScrollingMode = "scroll" HxSwapScrollingShow HxSwapScrollingMode = "show" )
func (HxSwapScrollingMode) String ¶ added in v1.0.2
func (s HxSwapScrollingMode) String() string
String ...
type HxSwapTiming ¶ added in v1.0.2
type HxSwapTiming struct {
// contains filtered or unexported fields
}
HxSwapTiming ...
type HxSwapTimingMode ¶ added in v1.0.2
type HxSwapTimingMode string
HxSwapTimingMode ...
const ( HxTimingSwap HxSwapTimingMode = "swap" HxTimingSettle HxSwapTimingMode = "settle" )
func (HxSwapTimingMode) String ¶ added in v1.0.2
func (s HxSwapTimingMode) String() string
String ...
type Node ¶ added in v1.0.1
Node is a node in the HTML tree.
func Attribute ¶ added in v1.0.1
Attribute is a node that renders an HTML attribute.
Example (Bool) ¶
package main import ( "os" htmx "github.com/zeiss/fiber-htmx" ) func main() { _ = htmx.Attribute("disabled", htmx.AsStr(true)).Render(os.Stdout) }
Output: disabled="true"
Example (Name_value) ¶
package main import ( "os" htmx "github.com/zeiss/fiber-htmx" ) func main() { _ = htmx.Attribute("href", "/").Render(os.Stdout) }
Output: href="/"
func AutoComplete ¶ added in v1.0.1
AutoComplete sets the autocomplete attribute for form elements.
func AutoFocus ¶ added in v1.0.1
func AutoFocus() Node
AutoFocus sets the autofocus attribute for form elements.
func AutoPlay ¶ added in v1.0.1
func AutoPlay() Node
AutoPlay sets the autoplay attribute for media elements.
func BlockQuote ¶ added in v1.0.1
BlockQuote represents an HTML blockquote element.
func Checked ¶ added in v1.0.1
func Checked() Node
Checked sets the checked attribute for input elements.
func ClipRule ¶ added in v1.0.2
ClipRule returns an SVG attribute node for specifying the clip rule. The clip rule determines how the clipping path is applied to the SVG element. The value of the clip rule is specified as a string. Example usage: ClipRule("evenodd")
func Controls ¶ added in v1.0.1
func Controls() Node
Controls sets the controls attribute for media elements.
func CrossOrigin ¶ added in v1.2.0
CrossOrigin sets the crossorigin attribute for elements.
func D ¶ added in v1.0.2
D returns an SVG attribute node for specifying the path data. The path data defines the shape of the SVG path element. The value of the path data is specified as a string. Example usage: D("M10 10 L20 20")
func DataAttribute ¶ added in v1.0.1
DataAttribute sets the data-{name} attribute for elements.
func DataElement ¶ added in v1.0.1
DataElement represents an HTML data element.
func Disabled ¶ added in v1.0.1
func Disabled() Node
Disabled sets the disabled attribute for form elements.
func FigCaption ¶ added in v1.0.1
FigCaption represents an HTML figcaption element.
func Fill ¶ added in v1.0.2
Fill returns an SVG attribute node for specifying the fill color. The fill color determines the color used to fill the SVG element. The value of the fill color is specified as a string. Example usage: Fill("red")
func FillRule ¶ added in v1.0.2
FillRule returns an SVG attribute node for specifying the fill rule. The fill rule determines how the interior of the SVG element is filled. The value of the fill rule is specified as a string. Example usage: FillRule("evenodd")
func FormAttribute ¶ added in v1.0.1
FormAttribute sets the form attribute for elements.
func FormElement ¶ added in v1.0.1
FormElement represents an HTML form element.
func HTML5 ¶ added in v1.0.1
func HTML5(props HTML5Props, body ...Node) Node
HTML5 generates an HTML5 document based on the provided properties.
func HandlebarsTemplate ¶ added in v1.0.33
HandlebarsTemplate sets the handlebars-template attribute to specify the handlebars template for the response.
func HxConfirm ¶ added in v1.0.1
HxConfirm sets the hx-confirm attribute to display a confirmation message.
func HxDelete ¶ added in v1.0.1
HxDelete sets the hx-delete attribute to specify the URL for DELETE requests.
func HxDisable ¶ added in v1.0.1
func HxDisable() Node
HxDisable sets the hx-disable attribute to disable htmx functionality.
func HxDisabledElt ¶ added in v1.1.36
HxDisabledElt sets the hx-disable-elt attribute to disable the target element.
func HxEncoding ¶ added in v1.0.1
HxEncoding sets the hx-encoding attribute to specify the encoding type for form submission.
func HxExt ¶ added in v1.0.1
HxExt sets the hx-ext attribute to specify the file extension for file uploads.
func HxInclude ¶ added in v1.0.32
HxInclude sets the hx-include attribute to specify the target element for inclusion.
func HxIndicator ¶ added in v1.0.1
HxIndicator sets the hx-indicator attribute to specify the target element for showing an indicator.
func HxOn ¶ added in v1.0.1
HxOn sets the hx-put-{target} attribute to specify the JavaScript code to execute on a PUT request.
func HxPath ¶ added in v1.0.1
HxPath sets the hx-patch attribute to specify the URL for PATCH requests.
func HxPost ¶ added in v1.0.1
HxPost sets the hx-post attribute to specify the URL for POST requests.
func HxPushUrl ¶ added in v1.0.1
HxPushUrl sets the hx-push-url attribute to enable or disable URL pushing.
func HxSelect ¶ added in v1.0.1
HxSelect sets the hx-select attribute to specify the target element for selection.
func HxSelectOob ¶ added in v1.0.1
HxSelectOob sets the hx-select-oob attribute to specify the target element for out-of-band selection.
func HxSwap ¶ added in v1.0.1
HxSwap sets the hx-swap attribute to specify the target element for swapping.
func HxSwapOob ¶ added in v1.0.1
HxSwapOob sets the hx-swap-oob attribute to specify the target element for out-of-band swapping.
func HxTarget ¶ added in v1.0.1
HxTarget sets the hx-target attribute to specify the target element for the response.
func HxTrigger ¶ added in v1.0.1
HxTrigger sets the hx-trigger attribute to specify the target element for triggering an event.
func HxValidate ¶ added in v1.0.1
HxValidate sets the hx-validate attribute to enable or disable form validation.
func HyperScript ¶ added in v1.1.8
HyperScript sets the _ attribute to specify the hyperscript for the response.
func Multiple ¶ added in v1.0.1
func Multiple() Node
Multiple sets the multiple attribute for input elements.
func MustacheTemplate ¶ added in v1.0.33
MustacheTemplate sets the mustache-template attribute to specify the mustache template for the response.
func NunjucksTemplate ¶ added in v1.0.33
NunjucksTemplate sets the nunjucks-template attribute to specify the nunjucks template for the response.
func Path ¶ added in v1.0.2
Path creates an SVG path element with the specified children. It is a convenience function that calls the Element function with "path" as the tag name.
func Placeholder ¶ added in v1.0.1
Placeholder sets the placeholder attribute for input elements.
func PlaysInline ¶ added in v1.0.1
func PlaysInline() Node
PlaysInline sets the playsinline attribute for media elements.
func ReadOnly ¶ added in v1.0.1
func ReadOnly() Node
ReadOnly sets the readonly attribute for form elements.
func Required ¶ added in v1.0.1
func Required() Node
Required sets the required attribute for form elements.
func SVG ¶ added in v1.0.1
SVG creates an SVG element with the specified children. It sets the "xmlns" attribute to "http://www.w3.org/2000/svg". The children are rendered inside a group element.
func Selected ¶ added in v1.0.1
func Selected() Node
Selected sets the selected attribute for option elements.
func Stroke ¶ added in v1.0.2
Stroke returns an SVG attribute node for specifying the stroke color. The stroke color determines the color used to stroke the SVG element. The value of the stroke color is specified as a string. Example usage: Stroke("blue")
func StrokeWidth ¶ added in v1.0.2
StrokeWidth returns an SVG attribute node for specifying the stroke width. The stroke width determines the thickness of the stroke applied to an SVG element. The value of the stroke width is specified as a string. Example usage: StrokeWidth("2px")
func StyleAttribute ¶ added in v1.0.1
StyleAttribute sets the style attribute for elements.
func StyleElement ¶ added in v1.0.1
StyleElement represents an HTML style element.
func TitleAttribute ¶ added in v1.0.1
TitleAttribute sets the title attribute for elements.
func TitleElement ¶ added in v1.0.1
TitleElement represents an HTML title element.
func ViewBox ¶ added in v1.0.2
ViewBox returns an SVG attribute node for specifying the viewBox. The viewBox defines the position and size of the SVG element's viewport. The value of the viewBox is specified as a string. Example usage: ViewBox("0 0 100 100")
func XSLTTemplat ¶ added in v1.0.33
XSLTTemplat sets the xslt-template attribute to specify the xslt template for the response.
type NodeFunc ¶ added in v1.0.1
NodeFunc is a function that renders a node.
func Element ¶ added in v1.0.1
Element is a node that renders an HTML element.
Example (A) ¶
_ = Element("a").Render(os.Stdout)
Output: <a></a>
Example (Div) ¶
_ = Element("div").Render(os.Stdout)
Output: <div></div>
Example (Tag) ¶
package main import ( "os" htmx "github.com/zeiss/fiber-htmx" ) func main() { _ = htmx.Element("div").Render(os.Stdout) }
Output: <div></div>
type NodeTypeDescriptor ¶ added in v1.0.1
type NodeTypeDescriptor interface {
Type() NodeType
}
NodeTypeDescriptor is a node that has a type.
type RangeLoop ¶ added in v1.0.38
type RangeLoop interface { // Filter loops and filters the content. Filter(f func(int) bool) RangeLoop // Map loops and maps the content. Map(f func(int) Node) RangeLoop // Group returns the nodes as a group. Group() Node }
RangeLoop is a loop control structure.
type RenderOpt ¶ added in v1.1.43
type RenderOpt func(c *fiber.Ctx)
RenderOpt is helper function to configure the render.
func RenderStatusCode ¶ added in v1.1.43
RenderStatusCode is a helper function to set the status code.
type Swap ¶ added in v1.0.2
type Swap struct {
// contains filtered or unexported fields
}
Swap ...
func (*Swap) FocusScroll ¶ added in v1.0.2
FocusScroll ...
func (*Swap) IgnoreTitle ¶ added in v1.0.2
IgnoreTitle ...
func (*Swap) Scroll ¶ added in v1.0.2
func (s *Swap) Scroll(direction HxSwapDirection, target ...string) *Swap
Scroll ...
func (*Swap) ScrollBottom ¶ added in v1.0.2
ScrollBottom ...
func (*Swap) Settle ¶ added in v1.0.2
Settle modifies the amount of time that htmx will wait after receiving a response to settle the content
func (*Swap) Show ¶ added in v1.0.2
func (s *Swap) Show(direction HxSwapDirection, target ...string) *Swap
Show ...
func (*Swap) ShowBottom ¶ added in v1.0.2
ShowBottom ...
func (*Swap) Swap ¶ added in v1.0.2
Swap modifies the amount of time that htmx will wait after receiving a response to swap the content
func (*Swap) Transition ¶ added in v1.0.2
Transition ...
type UnimplementedController ¶ added in v1.0.42
type UnimplementedController = DefaultController
UnimplementedController is not to be used anymore. Deprecated: Use DefaultController instead.