htmx

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: 0BSD Imports: 5 Imported by: 0

Documentation

Overview

Package htmx simplifies working with HTMX, especially in combination with Templ.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Renderer

type Renderer struct {
	// OnError is synchronously called when rendering fails.
	OnError func(error)
}

Renderer renders an HTMX template to an http.ResponseWriter.

func (Renderer) Render

func (r Renderer) Render(
	ctx context.Context,
	w http.ResponseWriter,
	template Template,
)

Render sets essential HTMX headers, renders the template, and notifies of any potential errors.

type RenderingMode

type RenderingMode int

RenderingMode indicates how to render the HTMX response.

const (
	FullPage RenderingMode = iota
	PartialUpdate
)

func RenderingModeFor

func RenderingModeFor(r *http.Request) RenderingMode

RenderingModeFor returns the RenderingMode for an http.Request.

func (RenderingMode) String

func (i RenderingMode) String() string

type Template

type Template interface {
	Render(ctx context.Context, w io.Writer) error
}

Template invoked by Renderer.Render.

Jump to

Keyboard shortcuts

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