Documentation
¶
Index ¶
- Constants
- Variables
- func Boosted(c *fiber.Ctx) bool
- func CurrentURL(c *fiber.Ctx) string
- func HistoryRestoreRequest(c *fiber.Ctx) bool
- func HxTriggers(c *fiber.Ctx, target string)
- func NewCompFuncHandler(handler CompFunc, config ...Config) fiber.Handler
- func NewCompHandler(n Node, config ...Config) fiber.Handler
- func NewControllerHandler(factory ControllerFactory, config ...Config) fiber.Handler
- func NewHtmxMessageHandler(config ...Config) fiber.Handler
- func NewHxControllerHandler(ctrl ControllerFactory, config ...Config) fiber.Handler
- func Prompt(c *fiber.Ctx) string
- func ReSelect(c *fiber.Ctx, target string)
- func ReSwap(c *fiber.Ctx, target string)
- func ReTarget(c *fiber.Ctx, target string)
- func Redirect(c *fiber.Ctx, url string)
- func RenderComp(c *fiber.Ctx, n Node, opt ...RenderOpt) error
- func RenderPartial(c *fiber.Ctx) bool
- func ReplaceURL(c *fiber.Ctx, url string)
- func Request(c *fiber.Ctx) bool
- func StopPolling(c *fiber.Ctx) error
- func Targets(c *fiber.Ctx) string
- func Trigger(c *fiber.Ctx, target string)
- func TriggerName(c *fiber.Ctx) string
- type ClassNames
- type CompFunc
- type Config
- type Controller
- type ControllerComponentFactory
- type ControllerFactory
- 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) 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) Init(ctx *fiber.Ctx) error
- func (c *DefaultController) IsDevelopment() bool
- func (c *DefaultController) IsProduction() bool
- func (c *DefaultController) Messages(msgs ...HtmxMessage)
- func (c *DefaultController) Options() error
- func (c *DefaultController) OriginalURL() string
- 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) Redirect(path string) error
- func (c *DefaultController) Render(node Node, opt ...RenderOpt) error
- func (c *DefaultController) Reset()
- func (c *DefaultController) Session() adapters.GothSession
- 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 DefaultTransactionController
- type ErrBoundaryFunc
- type Errors
- type FallbackFunc
- type FilterFunc
- type HTML5Props
- type HXSwapStyle
- type HtmxMessage
- type HtmxMessageHeader
- type HtmxMessages
- type HxClassName
- type HxEventType
- type HxExtType
- type HxRequestHeader
- type HxResponseHeader
- type HxResponseHeaders
- type HxSwapDirection
- type HxSwapScrolling
- type HxSwapScrollingMode
- type HxSwapTiming
- type HxSwapTimingMode
- type Imports
- 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 ContentEditable(v string) Node
- func ControllerComponent(ctrl Controller, fn ControllerComponentFactory) Node
- func Controls() Node
- func CrossOrigin(v string) Node
- func CustomElement(tag string, children ...Node) 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 ErrorBoundary(n ErrBoundaryFunc) Node
- func ErrorExists[K comparable](e Errors[K], key K, fn func(k K, v error) Node) Node
- func Fallback(n Node, f FallbackFunc) 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 Fragment(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 HxHeaders(headers map[string]string) Node
- func HxInclude(target string) Node
- func HxIndicator(target string) Node
- func HxOn(target string, js string) Node
- func HxPatch(url string) Node
- func HxPost(url string) Node
- func HxPrompt(msg string) Node
- func HxPushUrl(v bool) Node
- func HxPut(url string) Node
- func HxSSE() Node
- func HxSSEConnect(url string) Node
- func HxSSESwap(target 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 HxTarget401(target string) Node
- func HxTarget403(target string) Node
- func HxTarget404(target string) Node
- func HxTarget4xx(target string) Node
- func HxTarget500(target string) Node
- func HxTarget50x(target string) Node
- func HxTarget5xx(target string) Node
- func HxTargetError(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 IfElse(condition bool, n, elseN Node) Node
- func Img(children ...Node) Node
- func ImportMap(m Imports) 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 KeyExists[K comparable, V any](m map[K]V, key K, fn func(k K, v V) 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 List(v string) Node
- func Loading(v string) Node
- func Loop() Node
- func Main(children ...Node) Node
- func Mark(children ...Node) Node
- func Markdown(source []byte, opts ...goldmark.Option) 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 NoValidate() Node
- func NunjucksTemplate(v string) Node
- func Object(children ...Node) Node
- func Ol(children ...Node) Node
- func OnClick(v string) Node
- func OnePasswordIgnore() 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 Nodes
- 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 TransactionController
- type UnimplementedController
Examples ¶
Constants ¶
const ( ElementType = NodeType(iota) AttributeType )
const ( HxClssNameAddedSelector = ".htmx-added" HxClssNameIndicatorSelector = ".htmx-indicator" HxClssNameRequestSelector = ".htmx-request" HxClssNameSettlingSelector = ".htmx-settling" HxClssNameSwappingSelector = ".htmx-swapping" )
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{}, AuthzChecker: authz.NewNoop(), }
ConfigDefault is the default config.
Functions ¶
func Boosted ¶ added in v1.2.8
func Boosted(c *fiber.Ctx) bool
Boosted returns true if the request is boosted.
func CurrentURL ¶ added in v1.2.8
func CurrentURL(c *fiber.Ctx) string
CurrentURL returns the current URL.
func HistoryRestoreRequest ¶ added in v1.2.8
func HistoryRestoreRequest(c *fiber.Ctx) bool
HistoryRestoreRequest returns true if the request is a history restore request.
func HxTriggers ¶ added in v1.2.4
func HxTriggers(c *fiber.Ctx, target string)
Triggers is a helper function to trigger an event.
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 NewControllerHandler ¶ added in v1.2.8
func NewControllerHandler(factory ControllerFactory, config ...Config) fiber.Handler
NewControllerHandler returns a new htmx controller handler. nolint:gocyclo
func NewHtmxMessageHandler ¶ added in v1.3.15
func NewHtmxMessageHandler(config ...Config) fiber.Handler
NewHtmxMessageHandler is a helper function to handle htmx messages.
func NewHxControllerHandler ¶ added in v1.0.42
func NewHxControllerHandler(ctrl ControllerFactory, config ...Config) fiber.Handler
NewHxControllerHandler returns a new htmx controller handler. Deprecated: use NewControllerHandler instead.
func ReSelect ¶ added in v1.2.8
func ReSelect(c *fiber.Ctx, target string)
ReSelect is a helper function to reselect the response.
func ReSwap ¶ added in v1.2.8
func ReSwap(c *fiber.Ctx, target string)
ReSwap is a helper function to swap the response.
func ReTarget ¶ added in v1.2.8
func ReTarget(c *fiber.Ctx, target string)
ReTarget is a helper function to retarget the response.
func Redirect ¶ added in v1.2.8
func Redirect(c *fiber.Ctx, url string)
Redirect is a helper function to redirect the client.
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 ReplaceURL ¶ added in v1.2.8
func ReplaceURL(c *fiber.Ctx, url string)
ReplaceURL is a helper function to replace the current URL.
func Request ¶ added in v1.2.8
func Request(c *fiber.Ctx) bool
Request returns true if the request is an htmx request.
func StopPolling ¶ added in v1.2.4
func StopPolling(c *fiber.Ctx) error
StopPolling is a helper function to stop polling.
func Targets ¶ added in v1.2.8
func Targets(c *fiber.Ctx) string
Targets is a helper function to get the target.
func Trigger ¶ added in v1.2.8
func Trigger(c *fiber.Ctx, target string)
Trigger is a helper function to trigger an event.
func TriggerName ¶ added in v1.2.8
func TriggerName(c *fiber.Ctx) string
TriggerName is a helper function to get the trigger name.
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) 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 // AuthzChecker is a function that authenticates the user. AuthzChecker authz.AuthzChecker // 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 // Reset resets the controller. Reset() // Ctx returns the fiber.Ctx. Ctx() *fiber.Ctx }
Controller is the interface for the htmx controller.
type ControllerComponentFactory ¶ added in v1.3.22
type ControllerComponentFactory func(ctrl Controller) Node
RenderCompFunc is a helper function to render a component function.
type ControllerFactory ¶ added in v1.2.10
type ControllerFactory func() Controller
ControllerFactory is a factory function that creates a new 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) 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) Init ¶ added in v1.1.43
func (c *DefaultController) Init(ctx *fiber.Ctx) error
Init is called when the controller is initialized.
func (*DefaultController) IsDevelopment ¶ added in v1.3.24
func (c *DefaultController) IsDevelopment() bool
IsDevelopment returns true if the environment is development.
func (*DefaultController) IsProduction ¶ added in v1.3.24
func (c *DefaultController) IsProduction() bool
IsProduction returns true if the environment is production.
func (*DefaultController) Messages ¶ added in v1.3.15
func (c *DefaultController) Messages(msgs ...HtmxMessage)
Messages is a helper function to get the message from the context.
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) OriginalURL ¶ added in v1.3.23
func (c *DefaultController) OriginalURL() string
OriginalURL returns the original URL.
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 returns the path.
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) Redirect ¶ added in v1.3.12
func (c *DefaultController) Redirect(path string) error
Redirect redirects to the given path.
func (*DefaultController) Render ¶ added in v1.3.11
func (c *DefaultController) Render(node Node, opt ...RenderOpt) error
Render renders a component.
func (*DefaultController) Reset ¶ added in v1.2.0
func (c *DefaultController) Reset()
Reset resets the controller.
func (*DefaultController) Session ¶ added in v1.3.13
func (c *DefaultController) Session() adapters.GothSession
Session is a helper function to get the session from the context.
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 DefaultTransactionController ¶ added in v1.3.8
type DefaultTransactionController struct { *DefaultController // contains filtered or unexported fields }
DefaultTransactionController is the interface for the htmx transaction controller.
func NewTransactionController ¶ added in v1.3.8
func NewTransactionController() *DefaultTransactionController
NewTransactionController returns a new transaction controller.
func (*DefaultTransactionController) Begin ¶ added in v1.3.8
func (c *DefaultTransactionController) Begin(conn *gorm.DB) error
Begin begins a transaction.
func (*DefaultTransactionController) Commmit ¶ added in v1.3.8
func (c *DefaultTransactionController) Commmit() error
Commit commits the transaction.
func (*DefaultTransactionController) Rollback ¶ added in v1.3.8
func (c *DefaultTransactionController) Rollback() error
Rollback rolls back the transaction.
func (*DefaultTransactionController) Tx ¶ added in v1.3.8
func (c *DefaultTransactionController) Tx() *gorm.DB
Txn returns the transaction.
type ErrBoundaryFunc ¶ added in v1.3.20
type ErrBoundaryFunc func() Node
ErrBoundaryFunc is a function that returns a node.
type Errors ¶ added in v1.3.2
type Errors[K comparable] map[K]error
Errors is a slice of errors.
func FromValidationErrors ¶ added in v1.3.2
func FromValidationErrors[K comparable](errr []validator.FieldError) Errors[K]
Error is a node that renders an error.
type FallbackFunc ¶ added in v1.3.21
FallbackFunc is a function that returns a node.
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 HtmxMessage ¶ added in v1.3.15
type HtmxMessage struct { // Message is the message for the user. Message string `json:"message"` // Tags is the tag for the message e.g. info, warning, error, success. Tags string `json:"tags"` }
HtmxMessage is s struct that represents a message.
type HtmxMessageHeader ¶ added in v1.3.15
type HtmxMessageHeader struct { // Message is the message for the user. Messages *HtmxMessages `json:"messages"` }
HtmxMessageHeader is a struct that represents a message header.
func NewHtmxMessageHeader ¶ added in v1.3.15
func NewHtmxMessageHeader() *HtmxMessageHeader
NewHtmxMessageHeader returns a new htmx messages.
type HtmxMessages ¶ added in v1.3.15
type HtmxMessages []HtmxMessage
HtmxMessages is a slice of messages.
func MessagesFromContext ¶ added in v1.3.15
func MessagesFromContext(c *fiber.Ctx) *HtmxMessages
MessagesFromContext returns the messages from the context.
func (*HtmxMessages) Add ¶ added in v1.3.15
func (m *HtmxMessages) Add(msg ...HtmxMessage)
AddMessage adds a message to the messages.
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 ( HXDebug HxExtType = "debug" // The debug extension allows you to debug htmx requests. 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. HxExtSSE HxExtType = "sse" // The sse extension allows you to use Server-Sent Events (SSE) to stream updates to the client. HxResponseTargets HxExtType = "response-targets" // The response-target extension allows you to specify the target for the response. )
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 Imports ¶ added in v1.3.28
type Imports struct { // Imports is a map of module specifiers to URLs. Imports map[string]string `json:"imports"` // Scopes is a map of scopes to maps of module specifiers to URLs. Scopes map[string]map[string]string `json:"scopes,omitempty"` // Integrity is a map of URLs to integrity metadata. Integrity map[string]string `json:"integrity,omitempty"` }
Imports is following the WICG Import Maps proposal. sse https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap
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" "github.com/zeiss/pkg/conv" ) func main() { _ = htmx.Attribute("disabled", conv.String(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 ContentEditable ¶ added in v1.3.33
ContentEditable sets the contenteditable attribute for elements.
func ControllerComponent ¶ added in v1.3.22
func ControllerComponent(ctrl Controller, fn ControllerComponentFactory) Node
ControllerComponent is a helper function to render a controller component.
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 CustomElement ¶ added in v1.3.24
CustomElement represents a custom HTML element.
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 ErrorBoundary ¶ added in v1.3.20
func ErrorBoundary(n ErrBoundaryFunc) Node
ErrorBoundary is a node that catches panics and renders an error.
func ErrorExists ¶ added in v1.3.2
func ErrorExists[K comparable](e Errors[K], key K, fn func(k K, v error) Node) Node
ErrorExists is a node that renders a child node if an error exists.
func Fallback ¶ added in v1.3.20
func Fallback(n Node, f FallbackFunc) Node
Fallback is a node that renders a fallback node if a condition is false.
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 HxHeaders ¶ added in v1.3.23
HxHeaders sets the hx-headers attribute to specify the headers for the request.
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 HxPatch ¶ added in v1.2.8
HxPatch 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 HxSSE ¶ added in v1.3.18
func HxSSE() Node
HxSSE sets the sse attribute to specify the Server-Sent Events (SSE) URL.
func HxSSEConnect ¶ added in v1.3.18
HxSSEConnect sets the sse-connect attribute to specify the Server-Sent Events (SSE) URL.
func HxSSESwap ¶ added in v1.3.18
HxSSESwap sets the sse-swap attribute to specify the Server-Sent Events (SSE) swap.
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 HxTarget401 ¶ added in v1.3.2
HxTarget401 sets the hx-target-401 attribute to specify the target element for 401 responses.
func HxTarget403 ¶ added in v1.3.2
HxTarget403 sets the hx-target-403 attribute to specify the target element for 403 responses.
func HxTarget404 ¶ added in v1.3.2
HxTarget404 sets the hx-target-404 attribute to specify the target element for 404 responses.
func HxTarget4xx ¶ added in v1.3.2
HxTarget4xx sets the hx-target-4xx attribute to specify the target element for 4xx responses.
func HxTarget500 ¶ added in v1.3.2
HxTarget500 sets the hx-target-500 attribute to specify the target element for 500 responses.
func HxTarget50x ¶ added in v1.3.2
HxTarget50x sets the hx-target-50x attribute to specify the target element for 50x responses.
func HxTarget5xx ¶ added in v1.3.2
HxTarget5xx sets the hx-target-5xx attribute to specify the target element for 5xx responses.
func HxTargetError ¶ added in v1.3.2
HxTargetError sets the hx-target-error attribute to specify the target element for error responses.
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 IfElse ¶ added in v1.3.15
IfElse is a node that renders a child node if a condition is true, otherwise it renders another child node.
func KeyExists ¶ added in v1.3.2
func KeyExists[K comparable, V any](m map[K]V, key K, fn func(k K, v V) Node) Node
KeyExists is a node that renders a child node if a key exists in a map.
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 NoValidate ¶ added in v1.3.33
func NoValidate() Node
NoValidate sets the novalidate attribute for form elements.
func NunjucksTemplate ¶ added in v1.0.33
NunjucksTemplate sets the nunjucks-template attribute to specify the nunjucks template for the response.
func OnePasswordIgnore ¶ added in v1.3.11
func OnePasswordIgnore() Node
OnePasswordIgnore sets the data-1p-ignore attribute for elements.
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 Nodes ¶ added in v1.2.9
type Nodes []Node
Nodes is a slice of nodes.
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 TransactionController ¶ added in v1.3.8
type TransactionController interface { // Returns the transaction. Tx() *gorm.DB // Begin begins a transaction. Begin(*gorm.DB) error // Commit commits the transaction. Commmit() error // Rollback rolls back the transaction. Rollback() error }
TransactionController is the interface for a controller that also does database transactions.
type UnimplementedController ¶ added in v1.0.42
type UnimplementedController = DefaultController
UnimplementedController is not to be used anymore. Deprecated: Use DefaultController instead.