htmx

package module
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 16 Imported by: 0

README

🔨 HTMX

Go Reference Go Report Card Taylor Swift

A Go package to write HTML5 and HTMX components in Go. The package is designed to work with fiber and htmx.

Features

  • Write declartive HTML5 components in Go without using templates and with the full-power of a type-safe language, auto-completion, and refactoring.
  • Full support for HTMX components.
  • No dependencies on JavaScript frameworks.
  • Fast rendering of HTML5 and HTMX components.
  • Easy to use and learn.
  • Easy to extend and customize.
Example

Creating a button leveraging htmx is as easy as this.

htmx.Button(
    htmx.Attribute("type", "submit")
    htmx.Text("Button"),
    htmx.HxPost("/api/respond")
)

Installation

$ go get github.com/zeiss/fiber-htmx

Components

Write HTML5 and HTMX components in Go.

func HelloWorld() htmx.Node {
    return htmx.Div(
        htmx.ClassNames{
            "font-semibold",
        },
        htmx.Text("Hello World"),
    )
}

There are different types of composition. For example, passing children to a component.

func HelloWorld(children ...htmx.Node) htmx.Node {
    return htmx.Div(
        htmx.ClassNames{
            "font-semibold",
        },
        htmx.Text("Hello World"),
        htmx.Div(
            htmx.ClassNames{
                "text-red-500",
            },
            htmx.Group(children...),
        ),
    )
}

Styling of components is done with the htmx.ClassNames type.

func HelloWorld() htmx.Node {
    return htmx.Div(
        htmx.ClassNames{
            "font-semibold": true,
            "text-red-500": true,
        },
        htmx.Text("Hello World"),
    )
}

There are also helpers to make the life with styling easier by merging classes.

func HelloWorld(classes htmx.ClassNames) htmx.Node {
    return htmx.Div(
        htmx.Merge(
            htmx.ClassNames{
                "font-semibold",
                "text-red-500",
            },
            classes,
        )
        htmx.Text("Hello World"),
    )
}

There are additional complex components that help to write HTML5 and HTMX components in Go.

There is also the option to use htmx.Controller to encapsulate the logic of the components.


func NewHelloWorldController() htmx.ControllerFactory {
  return func() htmx.Controller {
		return &NewHelloWorldController{}
	}
}

type HelloWorldController struct {
    htmx.DefaultController
}

func (c *HelloWorldController) Get() error {
    return htmx.RenderComp(
		c.Ctx(),
		htmx.HTML5(
            htmx.HTML5Props{
                Title:    "index",
                Language: "en",
                Head: []htmx.Node{},
            },
            htmx.Div(
                htmx.ClassNames{},
                htmx.Text("Hello World"),
            ),
        ),
    )    
}

app := fiber.New()
app.Get("/", htmx.NewHxControllerHandler(NewHelloWorldController())

app.Listen(":3000")

Examples

See examples to understand the provided interfaces.

Benchmarks

BenchmarkElement-10                     12964440                77.40 ns/op
Benchmark_AttrRender-10                 16038232                74.15 ns/op
Benchmark_HTML5_Render-10                   1392            847193 ns/op
Benchmark_ClassNames_Render-10           3166761               378.2 ns/op

Rendering 10.000 nodes took >0.8ms. The package is fast enough to render HTML5 and HTMX components.

License

MIT

Documentation

Index

Examples

Constants

View Source
const (
	ElementType = NodeType(iota)
	AttributeType
)
View Source
const (
	// StatusStopPolling is a helper status code to stop polling.
	StatusStopPolling = 286
)

Variables

View Source
var (
	HxDefaultSwapDuration = 0 * time.Millisecond
	HxDefaultSettleDelay  = 20 * time.Millisecond
)
View Source
var ConfigDefault = Config{
	ErrorHandler: defaultErrorHandler,
	Filters:      []FilterFunc{},
}

ConfigDefault is the default config.

Functions

func AsBool

func AsBool(str string) bool

AsBool is a helper function that returns a boolean value based on the provided string.

func AsStr added in v1.0.1

func AsStr(v bool) string

AsStr is a helper function that returns a string value based on the provided boolean.

func AsValue added in v1.2.3

func AsValue[T any](v any) T

AsValue is a helper function that returns a value based on the provided pointer.

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 IntAsString added in v1.0.16

func IntAsString(v int) string

IntAsString is a helper function that returns a string value based on the provided integer.

func Locals added in v1.0.33

func Locals[V any](c *fiber.Ctx, key any, value ...V) V

Locals is a method that returns the local values.

func NewCompFuncHandler added in v1.0.4

func NewCompFuncHandler(handler CompFunc, config ...Config) fiber.Handler

NewCompFuncHandler returns a new comp handler.

func NewCompHandler added in v1.0.1

func NewCompHandler(n Node, config ...Config) fiber.Handler

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 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 Pluralize added in v1.2.0

func Pluralize(s string) string

Pluralize is a helper function that returns the plural form of the provided string.

func Prompt added in v1.2.8

func Prompt(c *fiber.Ctx) string

Prompt returns the prompt.

func PtrValue added in v1.2.3

func PtrValue[V any](v *V) V

PtrValue is a helper function that returns the value of the provided pointer.

func 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

func RenderComp(c *fiber.Ctx, n Node, opt ...RenderOpt) error

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 Resolve added in v1.2.6

func Resolve(ctx *fiber.Ctx, funcs ...ResolveFunc) error

Bind is a function that returns a BindFactory.

func Slug added in v1.2.0

func Slug(s string) string

Slug is a helper function that returns a slugified version of the provided string.

func StopPolling added in v1.2.4

func StopPolling(c *fiber.Ctx) error

StopPolling is a helper function to stop polling.

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.

func ValuePtr added in v1.2.3

func ValuePtr[V any](v V) *V

ValuePtr is a helper function that returns a pointer to the provided value.

func Values added in v1.2.6

func Values[V any](ctx context.Context, key any) V

Values is a helper type for user context.

Types

type ClassNames added in v1.0.1

type ClassNames map[string]bool

ClassNames represents a set of class names.

func Merge added in v1.0.28

func Merge(classNames ...ClassNames) ClassNames

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

func (ClassNames) Copy added in v1.2.4

func (c ClassNames) Copy(src ...ClassNames)

Copy is copying all class names from the src to dst.

func (ClassNames) Merge added in v1.0.4

func (c ClassNames) Merge(classNames ClassNames) ClassNames

Merge merges the provided class names into the class names.

func (ClassNames) Render added in v1.0.1

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

Render writes the class names to the provided writer.

func (ClassNames) String added in v1.0.1

func (c ClassNames) String() string

String returns the string representation of the ClassNames.

func (ClassNames) Type added in v1.0.1

func (c ClassNames) Type() NodeType

Type returns the node type of the ClassNames.

type CompFunc added in v1.0.4

type CompFunc func(c *fiber.Ctx) (Node, error)

CompFunc is a helper type for component functions.

type Config

type Config struct {
	// Next defines a function to skip this middleware when returned true.
	Next func(c *fiber.Ctx) bool

	// Filters is a list of filters that filter the context.
	Filters []FilterFunc

	// ErrorHandler is executed when an error is returned from fiber.Handler.
	//
	// Optional. Default: DefaultErrorHandler
	ErrorHandler fiber.ErrorHandler
}

Config ...

type Controller added in v1.0.42

type Controller interface {
	// Init is called when the controller is initialized.
	Init(ctx *fiber.Ctx) error
	// Prepare is called before the controller is executed.
	Prepare() error
	// Finalize is called after the controller is executed.
	Finalize() error
	// Get is called when the controller is executed with the GET method.
	Get() error
	// Post is called when the controller is executed with the POST method.
	Post() error
	// Put is called when the controller is executed with the PUT method.
	Put() error
	// Patch is called when the controller is executed with the PATCH method.
	Patch() error
	// Delete is called when the controller is executed with the DELETE method.
	Delete() error
	// Options is called when the controller is executed with the OPTIONS method.
	Options() error
	// Trace is called when the controller is executed with the TRACE method.
	Trace() error
	// Head  is called when the controller is executed with the HEAD method.
	Head() error
	// Error is called when an error occurs.
	Error(err error) error
	// Reset resets the controller.
	Reset()
	// Ctx returns the fiber.Ctx.
	Ctx() *fiber.Ctx
}

Controller is the interface for the htmx controller.

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) Options added in v1.1.43

func (c *DefaultController) Options() error

Options is called when the controller is executed with the OPTIONS method.

func (*DefaultController) Patch added in v1.1.43

func (c *DefaultController) Patch() error

Patch is called when the controller is executed with the PATCH method.

func (*DefaultController) Post added in v1.1.43

func (c *DefaultController) Post() error

Post is called when the controller is executed with the POST method.

func (*DefaultController) Prepare added in v1.1.43

func (c *DefaultController) Prepare() error

Prepare is called before the controller is executed.

func (*DefaultController) Put added in v1.1.43

func (c *DefaultController) Put() error

Put is called when the controller is executed with the PUT method.

func (*DefaultController) Reset added in v1.2.0

func (c *DefaultController) Reset()

Reset resets the controller.

func (*DefaultController) Trace added in v1.1.43

func (c *DefaultController) Trace() error

Trace is called when the controller is executed with the TRACE method.

func (*DefaultController) Values added in v1.1.49

func (c *DefaultController) Values(key any, value ...any) (val any)

Values is a helper function to get the values from the context.

func (*DefaultController) ValuesBool added in v1.1.49

func (c *DefaultController) ValuesBool(key any, value ...any) (val bool)

ValuesBool is a helper function to get the values as a bool from the context.

func (*DefaultController) ValuesInt added in v1.1.49

func (c *DefaultController) ValuesInt(key any, value ...any) (val int)

ValuesInt is a helper function to get the values as an int from the context.

func (*DefaultController) ValuesString added in v1.1.49

func (c *DefaultController) ValuesString(key any, value ...any) (val string)

ValuesString is a helper function to get the values as a string from the context.

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

func (HXSwapStyle) String added in v1.0.2

func (s HXSwapStyle) String() string

String ...

type HxClassName added in v1.0.1

type HxClassName string

HxClassName represents a class name for htmx elements.

const (
	HxClassNameAdded     HxClassName = "htmx-added"
	HxClassNameIndicator HxClassName = "htmx-indicator"
	HxClassNameRequest   HxClassName = "htmx-request"
	HxClassNameSettling  HxClassName = "htmx-settling"
	HxClassNameSwapping  HxClassName = "htmx-swapping"
)

func (HxClassName) String added in v1.0.1

func (c HxClassName) String() string

String returns the string representation of the HxClassName.

type HxEventType added in v1.0.1

type HxEventType string

HxEventType represents the type of htmx event.

const (
	HxEventTypeAbort            HxEventType = "htmx:abort"
	HxEventTypeAfterLoad        HxEventType = "htmx:afterLoad"
	HxEventTypeAfterProcessNode HxEventType = "htmx:afterProcessNode"
	HxEventTypeAfterRequest     HxEventType = "htmx:afterRequest"
)

List of predefined htmx event types.

func (HxEventType) String added in v1.0.1

func (e HxEventType) String() string

String returns the string representation of the HxEventType.

type HxExtType added in v1.0.33

type HxExtType string

HxExtType is a type for htmx extension types.

const (
	HxExtClassTools          HxExtType = "class-tools"           // The class-tools extension allows you to add and remove classes from elements.
	HxExtClientSideTemplates HxExtType = "client-side-templates" // The client-side-templates extension allows you to use client-side templates to render the response.
	HxExtIgnoreDebug         HxExtType = "ignore:debug"          // The ignore:debug extension allows you to ignore the debug header.
	HxExtJSON                HxExtType = "json-enc"              // The json-enc extension allows you to specify the JSON encoding for the response.
	HxExtMultiSwap           HxExtType = "multi-swap"            // The multi-swap extension allows you to swap multiple elements in a single response.
	HxExtPathDeps            HxExtType = "path-deps"             // The path-deps extension allows you to specify the dependencies for a path.
	HxResponseTargets        HxExtType = "response-targets"      // The response-target extension allows you to specify the target for the response.
)

func (HxExtType) String added in v1.0.33

func (v HxExtType) String() string

String returns the string representation of the htmx extension type.

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

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

func (HxSwapDirection) String added in v1.0.2

func (s HxSwapDirection) String() string

String ...

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

func (*HxSwapTiming) String added in v1.0.2

func (s *HxSwapTiming) String() string

String ...

type HxSwapTimingMode added in v1.0.2

type HxSwapTimingMode string

HxSwapTimingMode ...

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

func (HxSwapTimingMode) String added in v1.0.2

func (s HxSwapTimingMode) String() string

String ...

type Node added in v1.0.1

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

Node is a node in the HTML tree.

func A added in v1.0.1

func A(children ...Node) Node

A represents an HTML anchor element.

func Abbr added in v1.0.1

func Abbr(children ...Node) Node

Abbr represents an HTML abbr element.

func Accept added in v1.0.1

func Accept(v string) Node

Accept sets the accept attribute for file input elements.

func Action added in v1.0.1

func Action(v string) Node

Action sets the action attribute for form elements.

func Address added in v1.0.1

func Address(children ...Node) Node

Address represents an HTML address element.

func Alt added in v1.0.1

func Alt(v string) Node

Alt sets the alt attribute for image elements.

func Area added in v1.0.1

func Area(children ...Node) Node

Area represents an HTML area element.

func Aria added in v1.0.1

func Aria(name, v string) Node

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

func Article added in v1.0.1

func Article(children ...Node) Node

Article represents an HTML article element.

func As added in v1.0.1

func As(v string) Node

As sets the as attribute for link elements.

func Aside added in v1.0.1

func Aside(children ...Node) Node

Aside represents an HTML aside element.

func Async added in v1.0.1

func Async() Node

Async sets the async attribute for script elements.

func Attribute added in v1.0.1

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

func main() {
	_ = htmx.Attribute("disabled", htmx.AsStr(true)).Render(os.Stdout)
}
Output:

disabled="true"
Example (Name_value)
package main

import (
	"os"

	htmx "github.com/zeiss/fiber-htmx"
)

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

href="/"

func Audio added in v1.0.1

func Audio(children ...Node) Node

Audio represents an HTML audio element.

func AutoComplete added in v1.0.1

func AutoComplete(v string) Node

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 B added in v1.0.1

func B(children ...Node) Node

B represents an HTML b element.

func Base added in v1.0.1

func Base(children ...Node) Node

Base represents an HTML base element.

func BlockQuote added in v1.0.1

func BlockQuote(children ...Node) Node

BlockQuote represents an HTML blockquote element.

func Body added in v1.0.1

func Body(children ...Node) Node

Body represents an HTML body element.

func Br added in v1.0.1

func Br(children ...Node) Node

Br represents an HTML line break element.

func Button added in v1.0.1

func Button(children ...Node) Node

Button represents an HTML button element.

func Canvas added in v1.0.1

func Canvas(children ...Node) Node

Canvas represents an HTML canvas element.

func Caption added in v1.0.1

func Caption(children ...Node) Node

Caption represents an HTML caption element.

func Charset added in v1.0.1

func Charset(v string) Node

Charset sets the charset attribute for meta elements.

func Checked added in v1.0.1

func Checked() Node

Checked sets the checked attribute for input elements.

func Cite added in v1.0.1

func Cite(children ...Node) Node

Cite represents an HTML cite element.

func Class added in v1.0.1

func Class(v string) Node

Class sets the class attribute for elements.

func ClipRule added in v1.0.2

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 added in v1.0.1

func Code(children ...Node) Node

Code represents an HTML code element.

func Col added in v1.0.1

func Col(children ...Node) Node

Col represents an HTML col element.

func ColGroup added in v1.0.1

func ColGroup(children ...Node) Node

ColGroup represents an HTML colgroup element.

func ColSpan added in v1.0.1

func ColSpan(v string) Node

ColSpan sets the colspan attribute for table cells.

func Cols added in v1.0.1

func Cols(v string) Node

Cols sets the cols attribute for textarea elements.

func Comment added in v1.1.43

func Comment(comment string) Node

Comment represents an HTML comment.

func Content added in v1.0.1

func Content(v string) Node

Content sets the content attribute for meta elements.

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

func CrossOrigin(v string) Node

CrossOrigin sets the crossorigin attribute for elements.

func D added in v1.0.2

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 added in v1.0.1

func DElement(children ...Node) Node

DElement represents an HTML del element.

func DataAttribute added in v1.0.1

func DataAttribute(name, v string) Node

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

func DataElement added in v1.0.1

func DataElement(children ...Node) Node

DataElement represents an HTML data element.

func DataList added in v1.0.1

func DataList(children ...Node) Node

DataList represents an HTML datalist element.

func Dd added in v1.0.1

func Dd(children ...Node) Node

Dd represents an HTML dd element.

func Defer added in v1.0.1

func Defer() Node

Defer sets the defer attribute for script elements.

func Details added in v1.0.1

func Details(children ...Node) Node

Details represents an HTML details element.

func Dfn added in v1.0.1

func Dfn(children ...Node) Node

Dfn represents an HTML dfn element.

func Dialog added in v1.0.1

func Dialog(children ...Node) Node

Dialog represents an HTML dialog element.

func Disabled added in v1.0.1

func Disabled() Node

Disabled sets the disabled attribute for form elements.

func Div added in v1.0.1

func Div(children ...Node) Node

Div represents an HTML div element.

func Dl added in v1.0.1

func Dl(children ...Node) Node

Dl represents an HTML dl element.

func Doctype added in v1.0.1

func Doctype(sibling Node) Node

Doctype represents the HTML doctype declaration.

func Dt added in v1.0.1

func Dt(children ...Node) Node

Dt represents an HTML dt element.

func Em added in v1.0.1

func Em(children ...Node) Node

Em represents an HTML em element.

func Embed added in v1.0.1

func Embed(children ...Node) Node

Embed represents an HTML embed element.

func EncType added in v1.0.1

func EncType(v string) Node

EncType sets the enctype attribute for form elements.

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 FieldSet added in v1.0.1

func FieldSet(children ...Node) Node

FieldSet represents an HTML fieldset element.

func FigCaption added in v1.0.1

func FigCaption(children ...Node) Node

FigCaption represents an HTML figcaption element.

func Figure added in v1.0.1

func Figure(children ...Node) Node

Figure represents an HTML figure element.

func Fill added in v1.0.2

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 added in v1.0.2

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 added in v1.0.38

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 added in v1.0.1

func For(v string) Node

For sets the for attribute for label elements.

func Form added in v1.0.32

func Form(children ...Node) Node

Form represents an HTML form element.

func FormAttribute added in v1.0.1

func FormAttribute(v string) Node

FormAttribute sets the form attribute for elements.

func FormElement added in v1.0.1

func FormElement(children ...Node) Node

FormElement represents an HTML form element.

func Fragment added in v1.3.2

func Fragment(children ...Node) Node

Fragment is a node that renders a fragment of nodes.

func Group added in v1.0.1

func Group(children ...Node) Node

Group is a node that groups children nodes.

func H1 added in v1.0.1

func H1(children ...Node) Node

H1 represents an HTML h1 element.

func H2 added in v1.0.1

func H2(children ...Node) Node

H2 represents an HTML h2 element.

func H3 added in v1.0.1

func H3(children ...Node) Node

H3 represents an HTML h3 element.

func H4 added in v1.0.1

func H4(children ...Node) Node

H4 represents an HTML h4 element.

func H5 added in v1.0.1

func H5(children ...Node) Node

H5 represents an HTML h5 element.

func H6 added in v1.0.1

func H6(children ...Node) Node

H6 represents an HTML h6 element.

func HGroup added in v1.0.1

func HGroup(children ...Node) Node

HGroup represents an HTML hgroup element.

func HTML added in v1.0.1

func HTML(children ...Node) Node

HTML represents an HTML html 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

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 added in v1.0.1

func Height(v string) Node

Height sets the height attribute for elements.

func Hr added in v1.0.1

func Hr(children ...Node) Node

Hr represents an HTML horizontal rule element.

func Href added in v1.0.1

func Href(v string) Node

Href sets the href attribute for anchor elements.

func HxBoost added in v1.0.1

func HxBoost(v bool) Node

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

func HxConfirm added in v1.0.1

func HxConfirm(msg string) Node

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

func HxDelete added in v1.0.1

func HxDelete(url string) Node

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

func HxDisabledElt(target string) Node

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

func HxEncoding added in v1.0.1

func HxEncoding(enc string) Node

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

func HxExt added in v1.0.1

func HxExt(ext string) Node

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

func HxGet added in v1.0.1

func HxGet(url string) Node

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

func HxInclude added in v1.0.32

func HxInclude(target string) Node

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

func HxIndicator added in v1.0.1

func HxIndicator(target string) Node

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

func HxOn added in v1.0.1

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 added in v1.2.8

func HxPatch(url string) Node

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

func HxPost added in v1.0.1

func HxPost(url string) Node

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

func HxPrompt added in v1.0.1

func HxPrompt(msg string) Node

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

func HxPushUrl added in v1.0.1

func HxPushUrl(v bool) Node

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

func HxPut added in v1.0.1

func HxPut(url string) Node

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

func HxSelect added in v1.0.1

func HxSelect(target string) Node

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

func HxSelectOob added in v1.0.1

func HxSelectOob(target string) Node

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

func HxSwap added in v1.0.1

func HxSwap(target string) Node

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

func HxSwapOob added in v1.0.1

func HxSwapOob(target string) Node

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

func HxTarget added in v1.0.1

func HxTarget(target string) Node

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

func HxTarget401 added in v1.3.2

func HxTarget401(target string) Node

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

func HxTarget403 added in v1.3.2

func HxTarget403(target string) Node

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

func HxTarget404 added in v1.3.2

func HxTarget404(target string) Node

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

func HxTarget4xx added in v1.3.2

func HxTarget4xx(target string) Node

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

func HxTarget500 added in v1.3.2

func HxTarget500(target string) Node

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

func HxTarget50x added in v1.3.2

func HxTarget50x(target string) Node

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

func HxTarget5xx added in v1.3.2

func HxTarget5xx(target string) Node

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

func HxTargetError added in v1.3.2

func HxTargetError(target string) Node

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

func HxTrigger added in v1.0.1

func HxTrigger(target string) Node

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

func HxValidate added in v1.0.1

func HxValidate(v bool) Node

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

func HyperScript added in v1.1.8

func HyperScript(v string) Node

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

func I added in v1.0.1

func I(children ...Node) Node

I represents an HTML i element.

func ID added in v1.0.1

func ID(v string) Node

ID sets the id attribute for elements.

func IFrame added in v1.0.1

func IFrame(children ...Node) Node

IFrame represents an HTML iframe element.

func If added in v1.0.1

func If(condition bool, n Node) Node

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

func Img added in v1.0.1

func Img(children ...Node) Node

Img represents an HTML img element.

func Input added in v1.0.1

func Input(children ...Node) Node

Input represents an HTML input element.

func Ins added in v1.0.1

func Ins(children ...Node) Node

Ins represents an HTML ins element.

func Integrity added in v1.2.0

func Integrity(v string) Node

Integrity sets the integrity attribute for elements.

func Is added in v1.1.43

func Is(v string) Node

Is sets the is attribute for custom elements.

func Kbd added in v1.0.1

func Kbd(children ...Node) Node

Kbd represents an HTML kbd element.

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 Label added in v1.0.3

func Label(children ...Node) Node

Label represents an HTML label element.

func Lang added in v1.0.1

func Lang(v string) Node

Lang sets the lang attribute for elements.

func Legend added in v1.0.1

func Legend(children ...Node) Node

Legend represents an HTML legend element.

func Li added in v1.0.1

func Li(children ...Node) Node

Li represents an HTML li element.

func Link(children ...Node) Node

Link represents an HTML link element.

func Loading added in v1.0.1

func Loading(v string) Node

Loading sets the loading attribute for elements.

func Loop added in v1.0.1

func Loop() Node

Loop sets the loop attribute for media elements.

func Main added in v1.0.1

func Main(children ...Node) Node

Main represents an HTML main element.

func Map added in v1.0.38

func Map(f func(i int) Node, children ...Node) []Node

Map loops and maps the content.

func Mark added in v1.0.1

func Mark(children ...Node) Node

Mark represents an HTML mark element.

func Max added in v1.0.1

func Max(v string) Node

Max sets the max attribute for input elements.

func MaxLength added in v1.0.1

func MaxLength(v string) Node

MaxLength sets the maxlength attribute for input elements.

func Meta added in v1.0.1

func Meta(children ...Node) Node

Meta represents an HTML meta element.

func Meter added in v1.0.1

func Meter(children ...Node) Node

Meter represents an HTML meter element.

func Method added in v1.0.1

func Method(v string) Node

Method sets the method attribute for form elements.

func Min added in v1.0.1

func Min(v string) Node

Min sets the min attribute for input elements.

func MinLength added in v1.0.1

func MinLength(v string) Node

MinLength sets the minlength attribute for input elements.

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

func MustacheTemplate(v string) Node

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

func Muted added in v1.0.1

func Muted() Node

Muted sets the muted attribute for media elements.

func Name added in v1.0.1

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 added in v1.0.1

func NoScript(children ...Node) Node

NoScript represents an HTML noscript element.

func NunjucksTemplate added in v1.0.33

func NunjucksTemplate(v string) Node

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

func Object added in v1.0.1

func Object(children ...Node) Node

Object represents an HTML object element.

func Ol added in v1.0.1

func Ol(children ...Node) Node

Ol represents an HTML ol element.

func OnClick added in v1.0.41

func OnClick(v string) Node

OnClick sets the onclick attribute for elements.

func OptGroup added in v1.0.1

func OptGroup(children ...Node) Node

OptGroup represents an HTML optgroup element.

func Option added in v1.0.1

func Option(children ...Node) Node

Option represents an HTML option element.

func P added in v1.0.1

func P(children ...Node) Node

P represents an HTML p element.

func Param added in v1.0.1

func Param(children ...Node) Node

Param represents an HTML param element.

func Path added in v1.0.2

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 added in v1.0.1

func Pattern(v string) Node

Pattern sets the pattern attribute for input elements.

func Picture added in v1.0.1

func Picture(children ...Node) Node

Picture represents an HTML picture element.

func Placeholder added in v1.0.1

func Placeholder(v string) Node

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 Poster added in v1.0.1

func Poster(v string) Node

Poster sets the poster attribute for video elements.

func Pre added in v1.0.1

func Pre(children ...Node) Node

Pre represents an HTML pre element.

func Preload added in v1.0.1

func Preload(v string) Node

Preload sets the preload attribute for media elements.

func Progress added in v1.0.1

func Progress(children ...Node) Node

Progress represents an HTML progress element.

func Q added in v1.0.1

func Q(children ...Node) Node

Q represents an HTML q element.

func Raw added in v1.0.1

func Raw(t string) Node

Raw is a node that renders raw HTML.

func Rawf added in v1.0.1

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

Rawf is a node that renders a formatted raw HTML.

func ReadOnly added in v1.0.1

func ReadOnly() Node

ReadOnly sets the readonly attribute for form elements.

func Reduce added in v1.0.38

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

Reduce reduces the content to a single node.

func Rel added in v1.0.1

func Rel(v string) Node

Rel sets the rel attribute for link elements.

func Required added in v1.0.1

func Required() Node

Required sets the required attribute for form elements.

func Role added in v1.0.1

func Role(v string) Node

Role sets the role attribute for elements.

func RowSpan added in v1.0.1

func RowSpan(v string) Node

RowSpan sets the rowspan attribute for table cells.

func Rows added in v1.0.1

func Rows(v string) Node

Rows sets the rows attribute for textarea elements.

func S added in v1.0.1

func S(children ...Node) Node

S represents an HTML s element.

func SVG added in v1.0.1

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 added in v1.0.1

func Samp(children ...Node) Node

Samp represents an HTML samp element.

func Script added in v1.0.1

func Script(children ...Node) Node

Script represents an HTML script element.

func Section added in v1.0.1

func Section(children ...Node) Node

Section represents an HTML section element.

func Select added in v1.0.1

func Select(children ...Node) Node

Select represents an HTML select element.

func Selected added in v1.0.1

func Selected() Node

Selected sets the selected attribute for option elements.

func Slot added in v1.0.33

func Slot(children ...Node) Node

Slot represents an HTML slot element.

func Small added in v1.0.1

func Small(children ...Node) Node

Small represents an HTML small element.

func Source added in v1.0.1

func Source(children ...Node) Node

Source represents an HTML source element.

func Span added in v1.0.1

func Span(children ...Node) Node

Span represents an HTML span element.

func Src added in v1.0.1

func Src(v string) Node

Src sets the src attribute for elements.

func SrcSet added in v1.0.1

func SrcSet(v string) Node

SrcSet sets the srcset attribute for elements.

func Step added in v1.0.1

func Step(v string) Node

Step sets the step attribute for input elements.

func Stroke added in v1.0.2

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 added in v1.0.2

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 added in v1.0.1

func Strong(children ...Node) Node

Strong represents an HTML strong element.

func StyleAttribute added in v1.0.1

func StyleAttribute(v string) Node

StyleAttribute sets the style attribute for elements.

func StyleElement added in v1.0.1

func StyleElement(children ...Node) Node

StyleElement represents an HTML style element.

func Sub added in v1.0.1

func Sub(children ...Node) Node

Sub represents an HTML sub element.

func Summary added in v1.0.1

func Summary(children ...Node) Node

Summary represents an HTML summary element.

func Sup added in v1.0.1

func Sup(children ...Node) Node

Sup represents an HTML sup element.

func TBody added in v1.0.1

func TBody(children ...Node) Node

TBody represents an HTML tbody element.

func TFoot added in v1.0.1

func TFoot(children ...Node) Node

TFoot represents an HTML tfoot element.

func THead added in v1.0.1

func THead(children ...Node) Node

THead represents an HTML thead element.

func TabIndex added in v1.0.1

func TabIndex(v string) Node

TabIndex sets the tabindex attribute for elements.

func Table added in v1.0.1

func Table(children ...Node) Node

Table represents an HTML table element.

func Target added in v1.0.1

func Target(v string) Node

Target sets the target attribute for elements.

func Td added in v1.0.1

func Td(children ...Node) Node

Td represents an HTML td element.

func Template added in v1.0.33

func Template(children ...Node) Node

Template represents an HTML template element.

func Text added in v1.0.1

func Text(t string) Node

Text is a node that renders a text.

func Textarea added in v1.0.1

func Textarea(children ...Node) Node

Textarea represents an HTML textarea element.

func Textf added in v1.0.1

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

Textf is a node that renders a formatted text.

func Th added in v1.0.1

func Th(children ...Node) Node

Th represents an HTML th element.

func Time added in v1.0.1

func Time(children ...Node) Node

Time represents an HTML time element.

func Title added in v1.0.33

func Title(children ...Node) Node

Title represents an HTML title element.

func TitleAttribute added in v1.0.1

func TitleAttribute(v string) Node

TitleAttribute sets the title attribute for elements.

func TitleElement added in v1.0.1

func TitleElement(children ...Node) Node

TitleElement represents an HTML title element.

func Tr added in v1.0.1

func Tr(children ...Node) Node

Tr represents an HTML tr element.

func Track added in v1.0.33

func Track(children ...Node) Node

Track represents an HTML track element.

func Type added in v1.0.1

func Type(v string) Node

Type sets the type attribute for elements.

func U added in v1.0.1

func U(children ...Node) Node

U represents an HTML u element.

func Ul added in v1.0.1

func Ul(children ...Node) Node

Ul represents an HTML ul element.

func Value added in v1.0.1

func Value(v string) Node

Value sets the value attribute for elements.

func Var added in v1.0.1

func Var(children ...Node) Node

Var represents an HTML var element.

func Video added in v1.0.1

func Video(children ...Node) Node

Video represents an HTML video element.

func ViewBox added in v1.0.2

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 added in v1.0.1

func Wbr(children ...Node) Node

Wbr represents an HTML wbr element.

func Width added in v1.0.1

func Width(v string) Node

Width sets the width attribute for elements.

func XSLTTemplat added in v1.0.33

func XSLTTemplat(v string) Node

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

type NodeFunc added in v1.0.1

type NodeFunc func(io.Writer) error

NodeFunc is a function that renders a node.

func Element added in v1.0.1

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

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

<div></div>

func (NodeFunc) Render added in v1.0.1

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

Render renders the node.

func (NodeFunc) String added in v1.0.1

func (n NodeFunc) String() string

String returns the node as a string.

func (NodeFunc) Type added in v1.0.1

func (n NodeFunc) Type() NodeType

Type returns the node type.

type NodeType added in v1.0.1

type NodeType int

NodeType is the type of a node.

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.

func ForEach added in v1.2.8

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

ForEach loops over the content.

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.

func Range added in v1.0.38

func Range(nodes ...Node) RangeLoop

Range loops over the content.

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

func RenderStatusCode(err error) RenderOpt

RenderStatusCode is a helper function to set the status code.

type ResolveFunc added in v1.0.42

type ResolveFunc func(ctx *fiber.Ctx) (any, any, error)

ResolveFunc is a function that returns a context.

type Swap added in v1.0.2

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

Swap ...

func NewSwap added in v1.0.2

func NewSwap() *Swap

NewSwap ...

func (*Swap) FocusScroll added in v1.0.2

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

FocusScroll ...

func (*Swap) IgnoreTitle added in v1.0.2

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

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

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

ScrollBottom ...

func (*Swap) ScrollTop added in v1.0.2

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

ScrollTop ...

func (*Swap) Settle added in v1.0.2

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 added in v1.0.2

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

Show ...

func (*Swap) ShowBottom added in v1.0.2

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

ShowBottom ...

func (*Swap) ShowTop added in v1.0.2

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

ShowTop ...

func (*Swap) String added in v1.0.2

func (s *Swap) String() string

String ...

func (*Swap) Style added in v1.0.2

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

Style ...

func (*Swap) Swap added in v1.0.2

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 added in v1.0.2

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

Transition ...

type UnimplementedController added in v1.0.42

type UnimplementedController = DefaultController

UnimplementedController is not to be used anymore. Deprecated: Use DefaultController instead.

Directories

Path Synopsis
components
icons
Package icons provides a set of icons that can be used in the application.
Package icons provides a set of icons that can be used in the application.
internal

Jump to

Keyboard shortcuts

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