htmx

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2025 License: MIT Imports: 15 Imported by: 3

README

🔨 HTMX

Go Reference Go Report Card Taylor Swift

License

MIT

Documentation

Overview

Package htmx provides a set of functions for generating HTML attributes as nodes. These attributes can be used in conjunction with the Fiber framework and the htmx library.

Index

Examples

Constants

View Source
const (
	TriggerClick        = "click"
	TriggerClickOnce    = TriggerClick + " once"
	TriggerDblClick     = JSEventTypeDblClickEvent
	TriggerKeyUpEnter   = "keyup[keyCode==13]"
	TriggerEnterPressed = TriggerKeyUpEnter
	TriggerBlur         = "blur"
	TriggerEvery1s      = "every:1s"
	TriggerEvery2s      = "every:2s"
	TriggerEvery5s      = "every:5s"
	TriggerEvery10s     = "every:10s"
	TriggerEvery30s     = "every:30s"
	TriggerEvery1m      = "every:1m"
	TriggerLoad         = "onload"
)
View Source
const (
	ElementType = NodeType(iota)
	AttributeType
)
View Source
const (
	HxClssNameAddedSelector     = ".htmx-added"
	HxClssNameIndicatorSelector = ".htmx-indicator"
	HxClssNameRequestSelector   = ".htmx-request"
	HxClssNameSettlingSelector  = ".htmx-settling"
	HxClssNameSwappingSelector  = ".htmx-swapping"
)

Variables

View Source
var (
	HxDefaultSwapDuration = 0 * time.Millisecond
	HxDefaultSettleDelay  = 20 * time.Millisecond
)

Functions

func JSONSerializeOrEmpty

func JSONSerializeOrEmpty(data any) string

JSONSerializeOrEmpty returns a JSON serialized string of the provided data or an empty string if the serialization fails.

Types

type ClassNames

type ClassNames map[string]bool

ClassNames represents a set of class names.

func Merge

func Merge(classNames ...ClassNames) ClassNames

Merge returns a new ClassNames object that is the result of merging the provided ClassNames objects.

func (ClassNames) Render

func (c ClassNames) Render(w io.Writer) error

Render writes the class names to the provided writer.

func (ClassNames) String

func (c ClassNames) String() string

String returns the string representation of the ClassNames.

func (ClassNames) Type

func (c ClassNames) Type() NodeType

Type returns the node type of the ClassNames.

type ErrBoundaryFunc

type ErrBoundaryFunc func() Node

ErrBoundaryFunc is a function that returns a node.

type Errors

type Errors[K comparable] map[K]error

Errors is a slice of errors.

type FallbackFunc

type FallbackFunc func(error) Node

FallbackFunc is a function that returns a node.

type HTML5Props

type HTML5Props struct {
	// Title is the title of the HTML document.
	Title string
	// Description is the description of the HTML document.
	Description string
	// Language is the language of the HTML document.
	Language string
	// Head is the head section of the HTML document.
	Head []Node
	// Attributes are the attributes to be included in the HTML document.
	Attributes []Node
}

HTML5Props represents the properties for an HTML5 document.

type HXSwapStyle

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"
)

func (HXSwapStyle) String

func (s HXSwapStyle) String() string

String ...

type HxAttribute

const (
	HxAttributeBoost       HxAttribute = "hx-boost"
	HxAttributeGet         HxAttribute = "hx-get"
	HxAttributePost        HxAttribute = "hx-post"
	HxAttributePushURL     HxAttribute = "hx-push-url"
	HxAttributeTarget      HxAttribute = "hx-target"
	HxAttributeSelect      HxAttribute = "hx-select"
	HxAttributeSelectOob   HxAttribute = "hx-select-oob"
	HxAttributeSwap        HxAttribute = "hx-swap"
	HxAttributeSwapOob     HxAttribute = "hx-swap-oob"
	HxAttributeTrigger     HxAttribute = "hx-trigger"
	HxAttributeConfirm     HxAttribute = "hx-confirm"
	HxAttributePrompt      HxAttribute = "hx-prompt"
	HxAttributeDelete      HxAttribute = "hx-delete"
	HxAttributeOn          HxAttribute = "hx-on"
	HxAttributePut         HxAttribute = "hx-put"
	HxAttributePatch       HxAttribute = "hx-patch"
	HxAttributeIndicator   HxAttribute = "hx-indicator"
	HxAttributeEncoding    HxAttribute = "hx-encoding"
	HxAttributeExt         HxAttribute = "hx-ext"
	HxAttributeTarget404   HxAttribute = "hx-target-404"
	HxAttributeTarget403   HxAttribute = "hx-target-403"
	HxAttributeTarget401   HxAttribute = "hx-target-401"
	HxAttributeTarget500   HxAttribute = "hx-target-500"
	HxAttributeTarget5xx   HxAttribute = "hx-target-5xx"
	HxAttributeTarget4xx   HxAttribute = "hx-target-4xx"
	HxAttributeTargetError HxAttribute = "hx-target-error"
	HxAttributeTarget50x   HxAttribute = "hx-target-50x"
	HxAttributeDisable     HxAttribute = "hx-disable"
	HxAttributeDisabledElt HxAttribute = "hx-disabled-elt"
	HxAttributeValidate    HxAttribute = "hx-validate"
	HxAttributeInclude     HxAttribute = "hx-include"
	HxAttributeHeaders     HxAttribute = "hx-headers"
	HxAttributeVars        HxAttribute = "hx-vars"
	HxAttributeSync        HxAttribute = "hx-sync"
	HxAttributeParams      HxAttribute = "hx-params"
	HxAttributeVals        HxAttribute = "hx-vals"
)

func (HxAttribute) String

func (a HxAttribute) String() string

type HxClassName

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

func (c HxClassName) String() string

String returns the string representation of the HxClassName.

type HxEventType

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"
	HxEventTypeBeforeHistorySaveEvent     HxEventType = "htmx:beforeHistorySave"
	HxEventTypeBeforeOnAbort              HxEventType = "htmx:beforeOnAbort"
	HxEventTypeBeforeOnConfigRequest      HxEventType = "htmx:beforeOnConfigRequest"
	HxEventTypeBeforeOnConfigSwap         HxEventType = "htmx:beforeOnConfigSwap"
	HxEventTypeBeforeOnConfigTrigger      HxEventType = "htmx:beforeOnConfigTrigger"
	HxEventTypeBeforeOnError              HxEventType = "htmx:beforeOnError"
	HxEventTypeBeforeOnLoad               HxEventType = "htmx:beforeOnLoad"
	HxEventTypeBeforeOnRequest            HxEventType = "htmx:beforeOnRequest"
	HxEventTypeBeforeOnSettle             HxEventType = "htmx:beforeOnSettle"
	HxEventTypeBeforeOnSwap               HxEventType = "htmx:beforeOnSwap"
	HxEventTypeBeforeOnTrigger            HxEventType = "htmx:beforeOnTrigger"
	HxEventTypeBeforeRequest              HxEventType = "htmx:beforeRequest"
	HxEventTypeBeforeSettle               HxEventType = "htmx:beforeSettle"
	HxEventTypeBeforeSwap                 HxEventType = "htmx:beforeSwap"
	HxEventTypeConfigRequest              HxEventType = "htmx:configRequest"
	HxEventTypeConfigSwap                 HxEventType = "htmx:configSwap"
	HxEventTypeConfigTrigger              HxEventType = "htmx:configTrigger"
	HxEventTypeError                      HxEventType = "htmx:error"
	HxEventTypeHistoryCacheErrorEvent     HxEventType = "htmx:historyCacheError"
	HxEventTypeHistoryCacheMissErrorEvent HxEventType = "htmx:historyCacheMissError"
	HxEventTypeHistoryCacheMissEvent      HxEventType = "htmx:historyCacheMiss"
	HxEventTypeHistoryCacheMissLoadEvent  HxEventType = "htmx:historyCacheMissLoad"
	HxEventTypeHistoryRestoreEvent        HxEventType = "htmx:historyRestore"
	HxEventTypeLoad                       HxEventType = "htmx:load"
	HxEventTypeNoSSESourceErrorEvent      HxEventType = "htmx:noSSESourceError"
	HxEventTypeOnAbort                    HxEventType = "htmx:onAbort"
	HxEventTypeOnConfigRequest            HxEventType = "htmx:onConfigRequest"
	HxEventTypeOnConfigSwap               HxEventType = "htmx:onConfigSwap"
	HxEventTypeOnConfigTrigger            HxEventType = "htmx:onConfigTrigger"
	HxEventTypeOnError                    HxEventType = "htmx:onError"
	HxEventTypeOnLoad                     HxEventType = "htmx:onLoad"
	HxEventTypeOnLoadErrorEvent           HxEventType = "htmx:onLoadError"
	HxEventTypeOnRequest                  HxEventType = "htmx:onRequest"
	HxEventTypeOnSettle                   HxEventType = "htmx:onSettle"
	HxEventTypeOnSwap                     HxEventType = "htmx:onSwap"
	HxEventTypeOnTrigger                  HxEventType = "htmx:onTrigger"
	HxEventTypeOobAfterSwapEvent          HxEventType = "htmx:oobAfterSwap"
	HxEventTypeOobBeforeSwapEvent         HxEventType = "htmx:oobBeforeSwap"
	HxEventTypePromptEvent                HxEventType = "htmx:prompt"
	HxEventTypePushedIntoHistoryEvent     HxEventType = "htmx:pushedIntoHistory"
	HxEventTypeRequest                    HxEventType = "htmx:request"
	HxEventTypeResponseErrorEvent         HxEventType = "htmx:responseError"
	HxEventTypeSendErrorEvent             HxEventType = "htmx:sendError"
	HxEventTypeSettle                     HxEventType = "htmx:settle"
	HxEventTypeSseAfterMessageEvent       HxEventType = "htmx:sseAfterMessage"
	HxEventTypeSseBeforeMessageEvent      HxEventType = "htmx:sseBeforeMessage"
	HxEventTypeSseClosedEvent             HxEventType = "htmx:sseClose"
	HxEventTypeSseConnectedEvent          HxEventType = "htmx:sseOpen"
	HxEventTypeSseConnectingEvent         HxEventType = "htmx:sseConnecting"
	HxEventTypeSseErrorEvent              HxEventType = "htmx:sseError"
	HxEventTypeSSEErrorEvent              HxEventType = "htmx:sseError"
	HxEventTypeSSEOpenEvent               HxEventType = "htmx:sseOpen"
	HxEventTypeSwap                       HxEventType = "htmx:swap"
	HxEventTypeSwapErrorEvent             HxEventType = "htmx:swapError"
	HxEventTypeTargetErrorEvent           HxEventType = "htmx:targetError"
	HxEventTypeTimeoutEvent               HxEventType = "htmx:timeout"
	HxEventTypeTrigger                    HxEventType = "htmx:trigger"
	HxEventTypeValidationFailedEvent      HxEventType = "htmx:validation:failed"
	HxEventTypeValidationHaltedEvent      HxEventType = "htmx:validation:halted"
	HxEventTypeValidationValidateEvent    HxEventType = "htmx:validation:validate"
	HxEventTypeXhrAbortEvent              HxEventType = "htmx:xhr:abort"
	HxEventTypeXhrLoadEndEvent            HxEventType = "htmx:xhr:loadend"
	HxEventTypeXhrLoadStartEvent          HxEventType = "htmx:xhr:loadstart"
	HxEventTypeXhrProgressEvent           HxEventType = "htmx:xhr:progress"
	HxEventTypeOobErrorNoTargetEvent      HxEventType = "htmx:oobErrorNoTarget"
)

List of predefined htmx event types. See: https://htmx.org/reference/#events

func (HxEventType) String

func (e HxEventType) String() string

String returns the string representation of the HxEventType.

type HxExtType

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.
)

func (HxExtType) String

func (v HxExtType) String() string

String returns the string representation of the htmx extension type.

type HxSwapDirection

type HxSwapDirection string

HxSwapDirection ...

const (
	HxSwapDirectionTop    HxSwapDirection = "top"
	HxSwapDirectionBottom HxSwapDirection = "bottom"
)

func (HxSwapDirection) String

func (s HxSwapDirection) String() string

String ...

type HxSwapScrolling

type HxSwapScrolling struct {
	// contains filtered or unexported fields
}

HxSwapScrolling ...

func (*HxSwapScrolling) String

func (s *HxSwapScrolling) String() string

String ...

type HxSwapScrollingMode

type HxSwapScrollingMode string

HxSwapScrollingMode ...

const (
	HxSwapScrollingScroll HxSwapScrollingMode = "scroll"
	HxSwapScrollingShow   HxSwapScrollingMode = "show"
)

func (HxSwapScrollingMode) String

func (s HxSwapScrollingMode) String() string

String ...

type HxSwapTiming

type HxSwapTiming struct {
	// contains filtered or unexported fields
}

HxSwapTiming ...

func (*HxSwapTiming) String

func (s *HxSwapTiming) String() string

String ...

type HxSwapTimingMode

type HxSwapTimingMode string

HxSwapTimingMode ...

const (
	HxTimingSwap   HxSwapTimingMode = "swap"
	HxTimingSettle HxSwapTimingMode = "settle"
)

func (HxSwapTimingMode) String

func (s HxSwapTimingMode) String() string

String ...

type ImportMap

type ImportMap 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"`
}

ImportMap is a struct that represents an import map. sse https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap

func NewImportMap

func NewImportMap() ImportMap

NewImportMap creates a new import map.

type ImportsProp

type ImportsProp struct {
	Pkgs     []imports.ExactPackage
	Requires []imports.Require
	Resolver imports.Resolver
}

ImportsProp ...

type JSEventType

type JSEventType string

JSEventType represents the type of JavaScript event.

const (
	JSEventTypeClickEvent       JSEventType = "onclick"
	JSEventTypeChangeEvent      JSEventType = "onchange"
	JSEventTypeInputEvent       JSEventType = "oninput"
	JSEventTypeFocusEvent       JSEventType = "onfocus"
	JSEventTypeBlurEvent        JSEventType = "onblur"
	JSEventTypeKeyDownEvent     JSEventType = "onkeydown"
	JSEventTypeKeyUpEvent       JSEventType = "onkeyup"
	JSEventTypeKeyPressEvent    JSEventType = "onkeypress"
	JSEventTypeSubmitEvent      JSEventType = "onsubmit"
	JSEventTypeLoadDomEvent     JSEventType = "onload"
	JSEventTypeLoadEvent        JSEventType = "onload"
	JSEventTypeUnloadEvent      JSEventType = "onunload"
	JSEventTypeResizeEvent      JSEventType = "onresize"
	JSEventTypeScrollEvent      JSEventType = "onscroll"
	JSEventTypeDblClickEvent    JSEventType = "ondblclick"
	JSEventTypeMouseOverEvent   JSEventType = "onmouseover"
	JSEventTypeMouseOutEvent    JSEventType = "onmouseout"
	JSEventTypeMouseMoveEvent   JSEventType = "onmousemove"
	JSEventTypeMouseDownEvent   JSEventType = "onmousedown"
	JSEventTypeMouseUpEvent     JSEventType = "onmouseup"
	JSEventTypeContextMenuEvent JSEventType = "oncontextmenu"
	JSEventTypeDragStartEvent   JSEventType = "ondragstart"
	JSEventTypeDragEvent        JSEventType = "ondrag"
	JSEventTypeDragEnterEvent   JSEventType = "ondragenter"
	JSEventTypeDragLeaveEvent   JSEventType = "ondragleave"
	JSEventTypeDragOverEvent    JSEventType = "ondragover"
	JSEventTypeDropEvent        JSEventType = "ondrop"
	JSEventTypeDragEndEvent     JSEventType = "ondragend"
)

List of predefined JavaScript event types.

func (JSEventType) String

func (e JSEventType) String() string

String returns the string representation of the JSEventType.

type Node

type Node interface {
	Render(w io.Writer) error
}

Node is a node in the HTML tree.

func A

func A(children ...Node) Node

A represents an HTML anchor element.

func Abbr

func Abbr(children ...Node) Node

Abbr represents an HTML abbr element.

func Accept

func Accept(v string) Node

Accept sets the accept attribute for file input elements.

func Action

func Action(v string) Node

Action sets the action attribute for form elements.

func Address

func Address(children ...Node) Node

Address represents an HTML address element.

func Alt

func Alt(v string) Node

Alt sets the alt attribute for image elements.

func Area

func Area(children ...Node) Node

Area represents an HTML area element.

func Aria

func Aria(name, v string) Node

Aria sets the aria-{name} attribute for elements.

func Article

func Article(children ...Node) Node

Article represents an HTML article element.

func As

func As(v string) Node

As sets the as attribute for link elements.

func Aside

func Aside(children ...Node) Node

Aside represents an HTML aside element.

func Async

func Async() Node

Async sets the async attribute for script elements.

func Attribute

func Attribute(name string, value ...string) Node

Attribute is a node that renders an HTML attribute.

Example (Bool)
package main

import (
	"os"

	htmx "github.com/katallaxie/htmx"
	"github.com/katallaxie/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/katallaxie/htmx"
)

func main() {
	_ = htmx.Attribute("href", "/").Render(os.Stdout)
}
Output:

href="/"

func Audio

func Audio(children ...Node) Node

Audio represents an HTML audio element.

func AutoComplete

func AutoComplete(v string) Node

AutoComplete sets the autocomplete attribute for form elements.

func AutoFocus

func AutoFocus() Node

AutoFocus sets the autofocus attribute for form elements.

func AutoPlay

func AutoPlay() Node

AutoPlay sets the autoplay attribute for media elements.

func B

func B(children ...Node) Node

B represents an HTML b element.

func Base

func Base(children ...Node) Node

Base represents an HTML base element.

func BlockQuote

func BlockQuote(children ...Node) Node

BlockQuote represents an HTML blockquote element.

func Body

func Body(children ...Node) Node

Body represents an HTML body element.

func Br

func Br(children ...Node) Node

Br represents an HTML line break element.

func Button

func Button(children ...Node) Node

Button represents an HTML button element.

func Canvas

func Canvas(children ...Node) Node

Canvas represents an HTML canvas element.

func Caption

func Caption(children ...Node) Node

Caption represents an HTML caption element.

func Charset

func Charset(v string) Node

Charset sets the charset attribute for meta elements.

func Checked

func Checked() Node

Checked sets the checked attribute for input elements.

func Cite

func Cite(children ...Node) Node

Cite represents an HTML cite element.

func Class

func Class(v string) Node

Class sets the class attribute for elements.

func ClipRule

func ClipRule(v string) Node

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 Code

func Code(children ...Node) Node

Code represents an HTML code element.

func Col

func Col(children ...Node) Node

Col represents an HTML col element.

func ColGroup

func ColGroup(children ...Node) Node

ColGroup represents an HTML colgroup element.

func ColSpan

func ColSpan(v string) Node

ColSpan sets the colspan attribute for table cells.

func Cols

func Cols(v string) Node

Cols sets the cols attribute for textarea elements.

func Comment

func Comment(comment string) Node

Comment represents an HTML comment.

func Content

func Content(v string) Node

Content sets the content attribute for meta elements.

func ContentEditable

func ContentEditable(v string) Node

ContentEditable sets the contenteditable attribute for elements.

func Controls

func Controls() Node

Controls sets the controls attribute for media elements.

func CrossOrigin

func CrossOrigin(v string) Node

CrossOrigin sets the crossorigin attribute for elements.

func CustomElement

func CustomElement(tag string, children ...Node) Node

CustomElement represents a custom HTML element.

func D

func D(v string) Node

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 DElement

func DElement(children ...Node) Node

DElement represents an HTML del element.

func DataAttribute

func DataAttribute(name, v string) Node

DataAttribute sets the data-{name} attribute for elements.

func DataElement

func DataElement(children ...Node) Node

DataElement represents an HTML data element.

func DataList

func DataList(children ...Node) Node

DataList represents an HTML datalist element.

func Dd

func Dd(children ...Node) Node

Dd represents an HTML dd element.

func Defer

func Defer() Node

Defer sets the defer attribute for script elements.

func Details

func Details(children ...Node) Node

Details represents an HTML details element.

func Dfn

func Dfn(children ...Node) Node

Dfn represents an HTML dfn element.

func Dialog

func Dialog(children ...Node) Node

Dialog represents an HTML dialog element.

func Disabled

func Disabled() Node

Disabled sets the disabled attribute for form elements.

func Div

func Div(children ...Node) Node

Div represents an HTML div element.

func Dl

func Dl(children ...Node) Node

Dl represents an HTML dl element.

func Doctype

func Doctype(sibling Node) Node

Doctype represents the HTML doctype declaration.

func Dt

func Dt(children ...Node) Node

Dt represents an HTML dt element.

func Em

func Em(children ...Node) Node

Em represents an HTML em element.

func Embed

func Embed(children ...Node) Node

Embed represents an HTML embed element.

func Empty

func Empty() Node

Empty is a node that renders an empty string.

func EncType

func EncType(v string) Node

EncType sets the enctype attribute for form elements.

func ErrorBoundary

func ErrorBoundary(n ErrBoundaryFunc) Node

ErrorBoundary is a node that catches panics and renders an error.

func ErrorExists

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

func Fallback(n Node, f FallbackFunc) Node

Fallback is a node that renders a fallback node if a condition is false.

func FieldSet

func FieldSet(children ...Node) Node

FieldSet represents an HTML fieldset element.

func FigCaption

func FigCaption(children ...Node) Node

FigCaption represents an HTML figcaption element.

func Figure

func Figure(children ...Node) Node

Figure represents an HTML figure element.

func Fill

func Fill(v string) Node

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

func FillRule(v string) Node

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 Filter

func Filter(f func(n Node) bool, children ...Node) []Node

Filter loops and filters the content.

func Footer(children ...Node) Node

Footer represents an HTML footer element.

func For

func For(v string) Node

For sets the for attribute for label elements.

func Form

func Form(children ...Node) Node

Form represents an HTML form element.

func FormAttribute

func FormAttribute(v string) Node

FormAttribute sets the form attribute for elements.

func FormElement

func FormElement(children ...Node) Node

FormElement represents an HTML form element.

func Fragment

func Fragment(children ...Node) Node

Fragment is a node that renders a fragment of nodes.

func G

func G(children ...Node) Node

G creates an SVG group element with the specified children. It is a convenience function that calls the Element function with "g" as the tag name.

func Group

func Group(children ...Node) Node

Group is a node that groups children nodes.

func H1

func H1(children ...Node) Node

H1 represents an HTML h1 element.

func H2

func H2(children ...Node) Node

H2 represents an HTML h2 element.

func H3

func H3(children ...Node) Node

H3 represents an HTML h3 element.

func H4

func H4(children ...Node) Node

H4 represents an HTML h4 element.

func H5

func H5(children ...Node) Node

H5 represents an HTML h5 element.

func H6

func H6(children ...Node) Node

H6 represents an HTML h6 element.

func HGroup

func HGroup(children ...Node) Node

HGroup represents an HTML hgroup element.

func HTML

func HTML(children ...Node) Node

HTML represents an HTML html element.

func HTML5

func HTML5(props HTML5Props, body ...Node) Node

HTML5 generates an HTML5 document based on the provided properties.

func HandlebarsTemplate

func HandlebarsTemplate(v string) Node

HandlebarsTemplate sets the handlebars-template attribute to specify the handlebars template for the response.

func Head(children ...Node) Node

Head represents an HTML head element.

func Header(children ...Node) Node

Header represents an HTML header element.

func Height

func Height(v string) Node

Height sets the height attribute for elements.

func Hr

func Hr(children ...Node) Node

Hr represents an HTML horizontal rule element.

func Href

func Href(v string) Node

Href sets the href attribute for anchor elements.

func HxBoost

func HxBoost(v bool) Node

HxBoost sets the hx-boost attribute to enable or disable boosting.

func HxConfirm

func HxConfirm(msg string) Node

HxConfirm sets the hx-confirm attribute to display a confirmation message.

func HxDelete

func HxDelete(url string) Node

HxDelete sets the hx-delete attribute to specify the URL for DELETE requests.

func HxDisable

func HxDisable() Node

HxDisable sets the hx-disable attribute to disable htmx functionality.

func HxDisabledElt

func HxDisabledElt(target string) Node

HxDisabledElt sets the hx-disable-elt attribute to disable the target element.

func HxEncoding

func HxEncoding(enc string) Node

HxEncoding sets the hx-encoding attribute to specify the encoding type for form submission.

func HxExt

func HxExt(ext string) Node

HxExt sets the hx-ext attribute to specify the file extension for file uploads.

func HxGet

func HxGet(url string) Node

HxGet sets the hx-get attribute to specify the URL for GET requests.

func HxHeaders

func HxHeaders(headers map[string]string) Node

HxHeaders sets the hx-headers attribute to specify the headers for the request.

func HxInclude

func HxInclude(target string) Node

HxInclude sets the hx-include attribute to specify the target element for inclusion.

func HxIndicator

func HxIndicator(target string) Node

HxIndicator sets the hx-indicator attribute to specify the target element for showing an indicator.

func HxOn

func HxOn(target string, js string) Node

HxOn sets the hx-put-{target} attribute to specify the JavaScript code to execute on a PUT request.

func HxPatch

func HxPatch(url string) Node

HxPatch sets the hx-patch attribute to specify the URL for PATCH requests.

func HxPost

func HxPost(url string) Node

HxPost sets the hx-post attribute to specify the URL for POST requests.

func HxPrompt

func HxPrompt(msg string) Node

HxPrompt sets the hx-prompt attribute to display a prompt message.

func HxPushURL

func HxPushURL(v bool) Node

HxPushURL sets the hx-push-url attribute to enable or disable URL pushing.

func HxPut

func HxPut(url string) Node

HxPut sets the hx-put attribute to specify the URL for PUT requests.

func HxSSE

func HxSSE() Node

HxSSE sets the sse attribute to specify the Server-Sent Events (SSE) URL.

func HxSSEConnect

func HxSSEConnect(url string) Node

HxSSEConnect sets the sse-connect attribute to specify the Server-Sent Events (SSE) URL.

func HxSSESwap

func HxSSESwap(target string) Node

HxSSESwap sets the sse-swap attribute to specify the Server-Sent Events (SSE) swap.

func HxSelect

func HxSelect(target string) Node

HxSelect sets the hx-select attribute to specify the target element for selection.

func HxSelectOob

func HxSelectOob(target string) Node

HxSelectOob sets the hx-select-oob attribute to specify the target element for out-of-band selection.

func HxSwap

func HxSwap(target string) Node

HxSwap sets the hx-swap attribute to specify the target element for swapping.

func HxSwapOob

func HxSwapOob(target string) Node

HxSwapOob sets the hx-swap-oob attribute to specify the target element for out-of-band swapping.

func HxTarget

func HxTarget(target string) Node

HxTarget sets the hx-target attribute to specify the target element for the response.

func HxTarget4xx

func HxTarget4xx(target string) Node

HxTarget4xx sets the hx-target-4xx attribute to specify the target element for 4xx responses.

func HxTarget5xx

func HxTarget5xx(target string) Node

HxTarget5xx sets the hx-target-5xx attribute to specify the target element for 5xx responses.

func HxTarget50x

func HxTarget50x(target string) Node

HxTarget50x sets the hx-target-50x attribute to specify the target element for 50x responses.

func HxTarget401

func HxTarget401(target string) Node

HxTarget401 sets the hx-target-401 attribute to specify the target element for 401 responses.

func HxTarget403

func HxTarget403(target string) Node

HxTarget403 sets the hx-target-403 attribute to specify the target element for 403 responses.

func HxTarget404

func HxTarget404(target string) Node

HxTarget404 sets the hx-target-404 attribute to specify the target element for 404 responses.

func HxTarget500

func HxTarget500(target string) Node

HxTarget500 sets the hx-target-500 attribute to specify the target element for 500 responses.

func HxTargetError

func HxTargetError(target string) Node

HxTargetError sets the hx-target-error attribute to specify the target element for error responses.

func HxTrigger

func HxTrigger(targets ...string) Node

HxTrigger sets the hx-trigger attribute to specify the target element for triggering an event.

func HxValidate

func HxValidate(v bool) Node

HxValidate sets the hx-validate attribute to enable or disable form validation.

func HyperScript

func HyperScript(v string) Node

HyperScript sets the _ attribute to specify the hyperscript for the response.

func I

func I(children ...Node) Node

I represents an HTML i element.

func ID

func ID(v string) Node

ID sets the id attribute for elements.

func IFrame

func IFrame(children ...Node) Node

IFrame represents an HTML iframe element.

func If

func If(condition bool, n Node) Node

If is a node that renders a child node if a condition is true.

func IfElse

func IfElse(condition bool, n, elseN Node) Node

IfElse is a node that renders a child node if a condition is true, otherwise it renders another child node.

func Img

func Img(children ...Node) Node

Img represents an HTML img element.

func Imports

func Imports(props ImportsProp) Node

Imports ...

func Input

func Input(children ...Node) Node

Input represents an HTML input element.

func Ins

func Ins(children ...Node) Node

Ins represents an HTML ins element.

func Integrity

func Integrity(v string) Node

Integrity sets the integrity attribute for elements.

func Is

func Is(v string) Node

Is sets the is attribute for custom elements.

func JSEvent

func JSEvent(e JSEventType, value ...string) Node

JSEvent is a type that represents JavaScript events.

func Kbd

func Kbd(children ...Node) Node

Kbd represents an HTML kbd element.

func KeyExists

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 Label

func Label(children ...Node) Node

Label represents an HTML label element.

func Lang

func Lang(v string) Node

Lang sets the lang attribute for elements.

func Legend

func Legend(children ...Node) Node

Legend represents an HTML legend element.

func Li

func Li(children ...Node) Node

Li represents an HTML li element.

func Link(children ...Node) Node

Link represents an HTML link element.

func List

func List(v string) Node

List sets the list attribute for input elements.

func Loading

func Loading(v string) Node

Loading sets the loading attribute for elements.

func Loop

func Loop() Node

Loop sets the loop attribute for media elements.

func Main

func Main(children ...Node) Node

Main represents an HTML main element.

func Mark

func Mark(children ...Node) Node

Mark represents an HTML mark element.

func Markdown

func Markdown(source []byte, opts ...goldmark.Option) Node

Markdown is a node that renders a markdown.

func Max

func Max(v string) Node

Max sets the max attribute for input elements.

func MaxLength

func MaxLength(v string) Node

MaxLength sets the maxlength attribute for input elements.

func Meta

func Meta(children ...Node) Node

Meta represents an HTML meta element.

func Meter

func Meter(children ...Node) Node

Meter represents an HTML meter element.

func Method

func Method(v string) Node

Method sets the method attribute for form elements.

func Min

func Min(v string) Node

Min sets the min attribute for input elements.

func MinLength

func MinLength(v string) Node

MinLength sets the minlength attribute for input elements.

func Multiple

func Multiple() Node

Multiple sets the multiple attribute for input elements.

func MustacheTemplate

func MustacheTemplate(v string) Node

MustacheTemplate sets the mustache-template attribute to specify the mustache template for the response.

func Muted

func Muted() Node

Muted sets the muted attribute for media elements.

func Name

func Name(v string) Node

Name sets the name attribute for elements.

func Nav(children ...Node) Node

Nav represents an HTML nav element.

func NoScript

func NoScript(children ...Node) Node

NoScript represents an HTML noscript element.

func NoValidate

func NoValidate() Node

NoValidate sets the novalidate attribute for form elements.

func NunjucksTemplate

func NunjucksTemplate(v string) Node

NunjucksTemplate sets the nunjucks-template attribute to specify the nunjucks template for the response.

func Object

func Object(children ...Node) Node

Object represents an HTML object element.

func Ol

func Ol(children ...Node) Node

Ol represents an HTML ol element.

func OnClick

func OnClick(v string) Node

OnClick sets the onclick attribute for elements.

func OnePasswordIgnore

func OnePasswordIgnore() Node

OnePasswordIgnore sets the data-1p-ignore attribute for elements.

func OptGroup

func OptGroup(children ...Node) Node

OptGroup represents an HTML optgroup element.

func Option

func Option(children ...Node) Node

Option represents an HTML option element.

func P

func P(children ...Node) Node

P represents an HTML p element.

func Param

func Param(children ...Node) Node

Param represents an HTML param element.

func Path

func Path(children ...Node) Node

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 Pattern

func Pattern(v string) Node

Pattern sets the pattern attribute for input elements.

func Picture

func Picture(children ...Node) Node

Picture represents an HTML picture element.

func Placeholder

func Placeholder(v string) Node

Placeholder sets the placeholder attribute for input elements.

func PlaysInline

func PlaysInline() Node

PlaysInline sets the playsinline attribute for media elements.

func Poster

func Poster(v string) Node

Poster sets the poster attribute for video elements.

func Pre

func Pre(children ...Node) Node

Pre represents an HTML pre element.

func Preload

func Preload(v string) Node

Preload sets the preload attribute for media elements.

func Progress

func Progress(children ...Node) Node

Progress represents an HTML progress element.

func Q

func Q(children ...Node) Node

Q represents an HTML q element.

func Raw

func Raw(t string) Node

Raw is a node that renders raw HTML.

func RawScript

func RawScript(t string) Node

RawScript is a node that renders a raw script.

func Rawf

func Rawf(format string, a ...interface{}) Node

Rawf is a node that renders a formatted raw HTML.

func ReadOnly

func ReadOnly() Node

ReadOnly sets the readonly attribute for form elements.

func Reduce

func Reduce(f func(prev Node, next Node) Node, children ...Node) Node

Reduce reduces the content to a single node.

func Rel

func Rel(v string) Node

Rel sets the rel attribute for link elements.

func Required

func Required() Node

Required sets the required attribute for form elements.

func Role

func Role(v string) Node

Role sets the role attribute for elements.

func RowSpan

func RowSpan(v string) Node

RowSpan sets the rowspan attribute for table cells.

func Rows

func Rows(v string) Node

Rows sets the rows attribute for textarea elements.

func S

func S(children ...Node) Node

S represents an HTML s element.

func SVG

func SVG(children ...Node) Node

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 Samp

func Samp(children ...Node) Node

Samp represents an HTML samp element.

func Script

func Script(children ...Node) Node

Script represents an HTML script element.

func Section

func Section(children ...Node) Node

Section represents an HTML section element.

func Select

func Select(children ...Node) Node

Select represents an HTML select element.

func Selected

func Selected() Node

Selected sets the selected attribute for option elements.

func Slot

func Slot(children ...Node) Node

Slot represents an HTML slot element.

func Small

func Small(children ...Node) Node

Small represents an HTML small element.

func Source

func Source(children ...Node) Node

Source represents an HTML source element.

func Span

func Span(children ...Node) Node

Span represents an HTML span element.

func Src

func Src(v string) Node

Src sets the src attribute for elements.

func SrcSet

func SrcSet(v string) Node

SrcSet sets the srcset attribute for elements.

func Step

func Step(v string) Node

Step sets the step attribute for input elements.

func Stroke

func Stroke(v string) Node

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

func StrokeWidth(v string) Node

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 Strong

func Strong(children ...Node) Node

Strong represents an HTML strong element.

func StyleAttribute

func StyleAttribute(v string) Node

StyleAttribute sets the style attribute for elements.

func StyleElement

func StyleElement(children ...Node) Node

StyleElement represents an HTML style element.

func Sub

func Sub(children ...Node) Node

Sub represents an HTML sub element.

func Summary

func Summary(children ...Node) Node

Summary represents an HTML summary element.

func Sup

func Sup(children ...Node) Node

Sup represents an HTML sup element.

func TBody

func TBody(children ...Node) Node

TBody represents an HTML tbody element.

func TFoot

func TFoot(children ...Node) Node

TFoot represents an HTML tfoot element.

func THead

func THead(children ...Node) Node

THead represents an HTML thead element.

func TabIndex

func TabIndex(v string) Node

TabIndex sets the tabindex attribute for elements.

func Table

func Table(children ...Node) Node

Table represents an HTML table element.

func Target

func Target(v string) Node

Target sets the target attribute for elements.

func Td

func Td(children ...Node) Node

Td represents an HTML td element.

func Template

func Template(children ...Node) Node

Template represents an HTML template element.

func Text

func Text(t string) Node

Text is a node that renders a text.

func Textarea

func Textarea(children ...Node) Node

Textarea represents an HTML textarea element.

func Textf

func Textf(format string, a ...interface{}) Node

Textf is a node that renders a formatted text.

func Th

func Th(children ...Node) Node

Th represents an HTML th element.

func Time

func Time(children ...Node) Node

Time represents an HTML time element.

func Title

func Title(children ...Node) Node

Title represents an HTML title element.

func TitleAttribute

func TitleAttribute(v string) Node

TitleAttribute sets the title attribute for elements.

func TitleElement

func TitleElement(children ...Node) Node

TitleElement represents an HTML title element.

func Tr

func Tr(children ...Node) Node

Tr represents an HTML tr element.

func Track

func Track(children ...Node) Node

Track represents an HTML track element.

func Type

func Type(v string) Node

Type sets the type attribute for elements.

func U

func U(children ...Node) Node

U represents an HTML u element.

func Ul

func Ul(children ...Node) Node

Ul represents an HTML ul element.

func UnsafeRaw

func UnsafeRaw(t string) Node

UnsafeRaw is a node that renders an unsafe raw HTML.

func UnsafeRawScript

func UnsafeRawScript(t string) Node

UnsafeRawScript is a node that renders an unsafe raw script.

func UnsafeRawf

func UnsafeRawf(format string, a ...interface{}) Node

UnsafeRawf is a node that renders an unsafe formatted raw HTML.

func Value

func Value(v string) Node

Value sets the value attribute for elements.

func Var

func Var(children ...Node) Node

Var represents an HTML var element.

func Video

func Video(children ...Node) Node

Video represents an HTML video element.

func ViewBox

func ViewBox(v string) Node

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 Wbr

func Wbr(children ...Node) Node

Wbr represents an HTML wbr element.

func Width

func Width(v string) Node

Width sets the width attribute for elements.

func XSLTTemplat

func XSLTTemplat(v string) Node

XSLTTemplat sets the xslt-template attribute to specify the xslt template for the response.

type NodeFunc

type NodeFunc func(io.Writer) error

NodeFunc is a function that renders a node.

func Element

func Element(name string, children ...Node) NodeFunc

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/katallaxie/htmx"
)

func main() {
	_ = htmx.Element("div").Render(os.Stdout)
}
Output:

<div></div>

func (NodeFunc) Render

func (n NodeFunc) Render(w io.Writer) error

Render renders the node.

func (NodeFunc) String

func (n NodeFunc) String() string

String returns the node as a string.

func (NodeFunc) Type

func (n NodeFunc) Type() NodeType

Type returns the node type.

type NodeType

type NodeType int

NodeType is the type of a node.

type NodeTypeDescriptor

type NodeTypeDescriptor interface {
	Type() NodeType
}

NodeTypeDescriptor is a node that has a type.

type Nodes

type Nodes []Node

Nodes is a slice of nodes.

func ForEach

func ForEach[S ~[]E, E comparable](s S, f func(E, int) Node) Nodes

ForEach loops over the content.

func Map

func Map[T1 comparable, T2 any](m map[T1]T2, f func(T1, T2) Node) Nodes

Map is using a map to transform into htmx nodes.

type Swap

type Swap struct {
	// contains filtered or unexported fields
}

Swap ...

func NewSwap

func NewSwap() *Swap

NewSwap ...

func (*Swap) FocusScroll

func (s *Swap) FocusScroll(focusScroll bool) *Swap

FocusScroll is a boolean attribute that indicates whether the element should be scrolled into view after the swap.

func (*Swap) IgnoreTitle

func (s *Swap) IgnoreTitle(ignoreTitle bool) *Swap

IgnoreTitle is a boolean attribute that indicates whether the title of the page should be ignored.

func (*Swap) Scroll

func (s *Swap) Scroll(direction HxSwapDirection, target ...string) *Swap

Scroll ...

func (*Swap) ScrollBottom

func (s *Swap) ScrollBottom(target ...string) *Swap

ScrollBottom ...

func (*Swap) ScrollTop

func (s *Swap) ScrollTop(target ...string) *Swap

ScrollTop ...

func (*Swap) Settle

func (s *Swap) Settle(swap ...time.Duration) *Swap

Settle modifies the amount of time that htmx will wait after receiving a response to settle the content.

func (*Swap) Show

func (s *Swap) Show(direction HxSwapDirection, target ...string) *Swap

Show ...

func (*Swap) ShowBottom

func (s *Swap) ShowBottom(target ...string) *Swap

ShowBottom ...

func (*Swap) ShowTop

func (s *Swap) ShowTop(target ...string) *Swap

ShowTop ...

func (*Swap) String

func (s *Swap) String() string

String returns the string representation of the Swap.

func (*Swap) Style

func (s *Swap) Style(style HXSwapStyle) *Swap

Style ...

func (*Swap) Swap

func (s *Swap) Swap(swap ...time.Duration) *Swap

Swap modifies the amount of time that htmx will wait after receiving a response to swap the content.

func (*Swap) Transition

func (s *Swap) Transition(transition bool) *Swap

Transition is a boolean attribute that indicates whether the swap should be animated.

Directories

Path Synopsis
cmd
cli command
heroicons command
tailwind command
Package components contains Daisy UI components for Fiber.
Package components contains Daisy UI components for Fiber.
heroicons
Code generated by herogen; DO NOT EDIT.
Code generated by herogen; DO NOT EDIT.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL