Documentation
¶
Index ¶
- Constants
- Variables
- func BaseExtensions() string
- func Cached(duration time.Duration, cb GetElementFunc) func() *Element
- func CachedPerKey[K comparable](duration time.Duration, cb GetElementFuncWithKey[K]) func() *Element
- func CachedPerKeyT[K comparable, T any](duration time.Duration, cb GetElementFuncTWithKey[K, T]) func(T) *Element
- func CachedPerKeyT2[K comparable, T any, T2 any](duration time.Duration, cb GetElementFuncT2WithKey[K, T, T2]) func(T, T2) *Element
- func CachedPerKeyT3[K comparable, T any, T2 any, T3 any](duration time.Duration, cb GetElementFuncT3WithKey[K, T, T2, T3]) func(T, T2, T3) *Element
- func CachedPerKeyT4[K comparable, T any, T2 any, T3 any, T4 any](duration time.Duration, cb GetElementFuncT4WithKey[K, T, T2, T3, T4]) func(T, T2, T3, T4) *Element
- func CachedT[T any](duration time.Duration, cb GetElementFuncT[T]) func(T) *Element
- func CachedT2[T any, T2 any](duration time.Duration, cb GetElementFuncT2[T, T2]) func(T, T2) *Element
- func CachedT3[T any, T2 any, T3 any](duration time.Duration, cb GetElementFuncT3[T, T2, T3]) func(T, T2, T3) *Element
- func CachedT4[T any, T2 any, T3 any, T4 any](duration time.Duration, cb GetElementFuncT4[T, T2, T3, T4]) func(T, T2, T3, T4) *Element
- func CombineCommands(cmds ...Command) string
- func CurrentPath(ctx *RequestContext) string
- func Filter[T any](slice []T, predicate func(item T) bool) []T
- func Find[T any](slice []T, predicate func(item *T) bool) *T
- func GenId(len int) string
- func GetLogLevel() slog.Level
- func GetPartialPath(partial PartialFunc) string
- func GetPartialPathWithQs(partial func(ctx *RequestContext) *Partial, qs *Qs) string
- func GetQueryParam(ctx *RequestContext, key string) string
- func GroupBy[T any, K comparable](slice []T, key func(item T) K) map[K][]T
- func GroupByOrdered[T any, K comparable](slice []T, key func(item T) K) *orderedmap.Map[K, []T]
- func HtmlView(w http.ResponseWriter, page *Page) error
- func IfElse[T any](condition bool, node T, node2 T) T
- func IfElseLazy[T any](condition bool, cb1 func() T, cb2 func() T) T
- func IsDevelopment() bool
- func IsEmptyPartial(partial *Partial) bool
- func IsProduction() bool
- func IsWatchMode() bool
- func JsonSerializeOrEmpty(data any) string
- func Map[T, U any](slice []T, mapper func(item T) U) []U
- func MergeClasses(classes ...string) string
- func MultiLineQuotes(text string) string
- func PartialView(w http.ResponseWriter, partial *Partial) error
- func PartialViewWithHeaders(w http.ResponseWriter, headers *Headers, partial *Partial) error
- func Render(node Ren, opts ...RenderOpt) string
- func SetQueryParams(href string, qs *Qs) string
- func Start(opts AppOpts)
- func Ternary[T any](value bool, a T, b T) T
- func Unique[T any](slice []T, key func(item T) string) []T
- type App
- type AppOpts
- type AttributeMap
- type AttributeMapOrdered
- func AttributeList(children ...*AttributeR) *AttributeMapOrdered
- func AttributePairs(pairs ...string) *AttributeMapOrdered
- func Attributes(attributes *AttributeMap) *AttributeMapOrdered
- func Get(path string, trigger ...string) *AttributeMapOrdered
- func GetPartial(partial PartialFunc, trigger ...string) *AttributeMapOrdered
- func GetPartialWithQs(partial PartialFunc, qs *Qs, trigger string) *AttributeMapOrdered
- func GetWithQs(path string, qs *Qs, trigger string) *AttributeMapOrdered
- func NewAttributeMap(pairs ...string) *AttributeMapOrdered
- func Post(url string, trigger ...string) *AttributeMapOrdered
- func PostOnClick(url string) *AttributeMapOrdered
- func PostPartial(partial PartialFunc, triggers ...string) *AttributeMapOrdered
- func PostPartialOnClick(partial PartialFunc) *AttributeMapOrdered
- func PostPartialOnClickQs(partial PartialFunc, qs *Qs) *AttributeMapOrdered
- func PostPartialWithQs(partial PartialFunc, qs *Qs, trigger ...string) *AttributeMapOrdered
- func PostWithQs(url string, qs *Qs, trigger string) *AttributeMapOrdered
- type AttributeR
- func Action(value string) *AttributeR
- func AriaHidden(value bool) *AttributeR
- func AriaLabel(value string) *AttributeR
- func Attribute(key string, value string) *AttributeR
- func AutoComplete(value string) *AttributeR
- func AutoFocus() *AttributeR
- func Class(value ...string) *AttributeR
- func ClassF(format string, args ...interface{}) *AttributeR
- func Cols(value int) *AttributeR
- func Disabled() *AttributeR
- func Download(value bool) *AttributeR
- func Enctype(value string) *AttributeR
- func Height(value int) *AttributeR
- func HxExtension(value string) *AttributeR
- func HxIndicator(tag string) *AttributeR
- func HxTrigger(opts ...hx.TriggerEvent) *AttributeR
- func HxTriggerClick(opts ...hx.Modifier) *AttributeR
- func HxTriggerString(triggers ...string) *AttributeR
- func JoinAttributes(sep string, attrs ...*AttributeR) *AttributeR
- func Max(value string) *AttributeR
- func MaxLength(value int) *AttributeR
- func Method(value string) *AttributeR
- func Min(value string) *AttributeR
- func MinLength(value int) *AttributeR
- func Multiple() *AttributeR
- func NewAttribute(name string, value string) *AttributeR
- func NoSwap() *AttributeR
- func NoValidate() *AttributeR
- func Pattern(value string) *AttributeR
- func ReadOnly() *AttributeR
- func Rel(value string) *AttributeR
- func Required() *AttributeR
- func Role(value string) *AttributeR
- func Rows(value int) *AttributeR
- func Selected() *AttributeR
- func Size(value int) *AttributeR
- func Src(src string) *AttributeR
- func Step(value string) *AttributeR
- func TabIndex(value int) *AttributeR
- func TriggerChildren() *AttributeR
- func Value(value any) *AttributeR
- func Width(value int) *AttributeR
- func Wrap(value string) *AttributeR
- type ByKeyEntry
- type CachedNode
- type ChildList
- type ClassMap
- type Command
- type ComplexJsCommand
- func EvalCommands(element *Element, cmds ...Command) ComplexJsCommand
- func EvalCommandsOnSelector(selector string, cmds ...Command) ComplexJsCommand
- func EvalJs(js string) ComplexJsCommand
- func EvalJsOnChildren(selector, js string) ComplexJsCommand
- func EvalJsOnParent(js string) ComplexJsCommand
- func EvalJsOnSibling(selector, js string) ComplexJsCommand
- func InjectScript(src string) ComplexJsCommand
- func InjectScriptIfNotExist(src string) ComplexJsCommand
- func NewComplexJsCommand(command string) ComplexJsCommand
- func RemoveClassOnChildren(selector, class string) ComplexJsCommand
- func RemoveClassOnParent(class string) ComplexJsCommand
- func RemoveClassOnSibling(selector, class string) ComplexJsCommand
- func RunAfterTimeout(time time.Duration, cmds ...Command) ComplexJsCommand
- func RunOnInterval(time time.Duration, cmds ...Command) ComplexJsCommand
- func SetClassOnChildren(selector, class string) ComplexJsCommand
- func SetClassOnParent(class string) ComplexJsCommand
- func SetClassOnSibling(selector, class string) ComplexJsCommand
- func SetTextOnChildren(selector, text string) ComplexJsCommand
- func SubmitFormOnEnter() ComplexJsCommand
- func ToggleClassOnChildren(selector, class string) ComplexJsCommand
- func ToggleClassOnElement(selector, class string) ComplexJsCommand
- func ToggleClassOnParent(class string) ComplexJsCommand
- func ToggleClassOnSibling(selector, class string) ComplexJsCommand
- type CustomElement
- type Element
- func A(children ...Ren) *Element
- func Abbr(children ...Ren) *Element
- func Address(children ...Ren) *Element
- func AppendChildren(node *Element, children ...Ren) *Element
- func Article(children ...Ren) *Element
- func Aside(children ...Ren) *Element
- func Body(children ...Ren) *Element
- func Br() *Element
- func Button(children ...Ren) *Element
- func Checkbox(children ...Ren) *Element
- func Code(children ...Ren) *Element
- func Dd(children ...Ren) *Element
- func Details(children ...Ren) *Element
- func Dialog(children ...Ren) *Element
- func Div(children ...Ren) *Element
- func Dl(children ...Ren) *Element
- func Dt(children ...Ren) *Element
- func ElementIf(condition bool, element *Element) *Element
- func Empty() *Element
- func FieldSet(children ...Ren) *Element
- func FileInput(children ...Ren) *Element
- func Footer(children ...Ren) *Element
- func Form(children ...Ren) *Element
- func Fragment(children ...Ren) *Element
- func H1(children ...Ren) *Element
- func H1F(format string, args ...interface{}) *Element
- func H2(children ...Ren) *Element
- func H2F(format string, args ...interface{}) *Element
- func H3(children ...Ren) *Element
- func H3F(format string, args ...interface{}) *Element
- func H4(children ...Ren) *Element
- func H4F(format string, args ...interface{}) *Element
- func H5(children ...Ren) *Element
- func H5F(format string, args ...interface{}) *Element
- func H6(children ...Ren) *Element
- func H6F(format string, args ...interface{}) *Element
- func Head(children ...Ren) *Element
- func Header(children ...Ren) *Element
- func Hr(children ...Ren) *Element
- func Html(children ...Ren) *Element
- func I(children ...Ren) *Element
- func IFrame(src string, children ...Ren) *Element
- func IfElseE(condition bool, element *Element, element2 *Element) *Element
- func Img(children ...Ren) *Element
- func Input(inputType string, children ...Ren) *Element
- func IterMap[T any](m map[string]T, mapper func(key string, value T) *Element) *Element
- func Label(children ...Ren) *Element
- func LabelFor(id string, text string) *Element
- func Li(children ...Ren) *Element
- func Link(href string, rel string) *Element
- func LinkWithVersion(href string, rel string, version string) *Element
- func List[T any](items []T, mapper func(item T, index int) *Element) *Element
- func Main(children ...Ren) *Element
- func Meta(name string, content string) *Element
- func Nav(children ...Ren) *Element
- func NumberInput(children ...Ren) *Element
- func Ol(children ...Ren) *Element
- func OobSwap(ctx *RequestContext, content *Element, option ...SwapOption) *Element
- func OobSwapWithSelector(ctx *RequestContext, selector string, content *Element, option ...SwapOption) *Element
- func Option(children ...Ren) *Element
- func P(children ...Ren) *Element
- func Path(children ...Ren) *Element
- func Pf(format string, args ...interface{}) *Element
- func Pre(children ...Ren) *Element
- func Radio(children ...Ren) *Element
- func Script(url string) *Element
- func ScriptWithVersion(url string, version string) *Element
- func Section(children ...Ren) *Element
- func Select(children ...Ren) *Element
- func Span(children ...Ren) *Element
- func Strong(children ...Ren) *Element
- func Style(text string) *Element
- func Summary(children ...Ren) *Element
- func Svg(children ...Ren) *Element
- func SwapMany(ctx *RequestContext, elements ...*Element) *Element
- func SwapManyX(ctx *RequestContext, args ...SwapArg) *Element
- func TBody(children ...Ren) *Element
- func TFoot(children ...Ren) *Element
- func THead(children ...Ren) *Element
- func Table(children ...Ren) *Element
- func Tag(tag string, children ...Ren) *Element
- func TagF(tag string, format string, args ...interface{}) *Element
- func Td(children ...Ren) *Element
- func Template(children ...Ren) *Element
- func TextArea(children ...Ren) *Element
- func TextInput(children ...Ren) *Element
- func Th(children ...Ren) *Element
- func Title(children ...Ren) *Element
- func Tr(children ...Ren) *Element
- func Ul(children ...Ren) *Element
- func Video(children ...Ren) *Element
- type Entry
- type GetElementFunc
- type GetElementFuncT
- type GetElementFuncT2
- type GetElementFuncT2WithKey
- type GetElementFuncT3
- type GetElementFuncT3WithKey
- type GetElementFuncT4
- type GetElementFuncT4WithKey
- type GetElementFuncTWithKey
- type GetElementFuncWithKey
- type Headers
- type KeyValue
- type LifeCycle
- func HxAfterRequest(cmd ...Command) *LifeCycle
- func HxAfterSseMessage(cmd ...Command) *LifeCycle
- func HxBeforeRequest(cmd ...Command) *LifeCycle
- func HxBeforeSseMessage(cmd ...Command) *LifeCycle
- func HxOnAfterSwap(cmd ...Command) *LifeCycle
- func HxOnLoad(cmd ...Command) *LifeCycle
- func HxOnMutationError(cmd ...Command) *LifeCycle
- func HxOnSseClose(cmd ...Command) *LifeCycle
- func HxOnSseConnecting(cmd ...Command) *LifeCycle
- func HxOnSseError(cmd ...Command) *LifeCycle
- func HxOnSseOpen(cmd ...Command) *LifeCycle
- func NewLifeCycle() *LifeCycle
- func OnClick(cmd ...Command) *LifeCycle
- func OnEvent(event hx.Event, cmd ...Command) *LifeCycle
- func OnLoad(cmd ...Command) *LifeCycle
- func OnSubmit(cmd ...Command) *LifeCycle
- func (l *LifeCycle) HxAfterRequest(cmd ...Command) *LifeCycle
- func (l *LifeCycle) HxBeforeRequest(cmd ...Command) *LifeCycle
- func (l *LifeCycle) HxOnMutationError(cmd ...Command) *LifeCycle
- func (l *LifeCycle) OnEvent(event hx.Event, cmd ...Command) *LifeCycle
- func (l *LifeCycle) Render(context *RenderContext)
- type Page
- type Partial
- func EmptyPartial() *Partial
- func NewPartial(root *Element) *Partial
- func NewPartialWithHeaders(headers *Headers, root *Element) *Partial
- func RedirectPartial(path string) *Partial
- func RedirectPartialWithHeaders(path string, headers *Headers) *Partial
- func SwapManyPartial(ctx *RequestContext, swaps ...*Element) *Partial
- func SwapManyPartialWithHeaders(ctx *RequestContext, headers *Headers, swaps ...*Element) *Partial
- func SwapManyXPartial(ctx *RequestContext, swaps ...SwapArg) *Partial
- func SwapPartial(ctx *RequestContext, swap *Element) *Partial
- type PartialFunc
- type Qs
- type RawContent
- type Ren
- func Alt(value string) Ren
- func AttributeIf(condition bool, name string, value string) Ren
- func Boost() Ren
- func Checked() Ren
- func ClassIf(condition bool, value string) Ren
- func ClassX(value string, m ClassMap) Ren
- func Controls() Ren
- func D(value string) Ren
- func For(value string) Ren
- func Hidden() Ren
- func Href(path string) Ren
- func HxConfirm(message string) Ren
- func HxExtensions(value ...string) Ren
- func HxInclude(selector string) Ren
- func HxTarget(target string) Ren
- func Id(value string) Ren
- func If(condition bool, node Ren) Ren
- func IfHtmxRequest(ctx *RequestContext, node Ren) Ren
- func IfQueryParam(key string, node *Element) Ren
- func JoinExtensions(attrs ...*AttributeR) Ren
- func Name(name string) Ren
- func Placeholder(placeholder string) Ren
- func Target(target string) Ren
- func Type(name string) Ren
- type RenderContext
- type RenderOpt
- type RenderOptions
- type RequestContext
- func (c *RequestContext) FormValue(key string) string
- func (c *RequestContext) Get(key string) interface{}
- func (c *RequestContext) Header(key string) string
- func (c *RequestContext) HxCurrentBrowserUrl() string
- func (c *RequestContext) HxPromptResponse() string
- func (c *RequestContext) HxTargetId() string
- func (c *RequestContext) HxTriggerId() string
- func (c *RequestContext) HxTriggerName() string
- func (c *RequestContext) IsBoosted() bool
- func (c *RequestContext) IsHttpDelete() bool
- func (c *RequestContext) IsHttpGet() bool
- func (c *RequestContext) IsHttpPost() bool
- func (c *RequestContext) IsHttpPut() bool
- func (c *RequestContext) IsHxRequest() bool
- func (c *RequestContext) QueryParam(key string) string
- func (c *RequestContext) Redirect(path string, code int)
- func (c *RequestContext) ServiceLocator() *service.Locator
- func (c *RequestContext) Set(key string, value interface{})
- func (c *RequestContext) SetCookie(cookie *http.Cookie)
- func (c *RequestContext) UrlParam(key string) string
- type ScriptEntry
- type SimpleJsCommand
- func AddAttribute(name, value string) SimpleJsCommand
- func AddClass(class string) SimpleJsCommand
- func Alert(text string) SimpleJsCommand
- func ConsoleLog(text string) SimpleJsCommand
- func Increment(amount int) SimpleJsCommand
- func PreventDefault() SimpleJsCommand
- func Remove() SimpleJsCommand
- func RemoveAttribute(name string) SimpleJsCommand
- func RemoveClass(class string) SimpleJsCommand
- func SetDisabled(disabled bool) SimpleJsCommand
- func SetInnerHtml(r Ren) SimpleJsCommand
- func SetOuterHtml(r Ren) SimpleJsCommand
- func SetText(text string) SimpleJsCommand
- func SetValue(value string) SimpleJsCommand
- func ToggleClass(class string) SimpleJsCommand
- type SwapArg
- type SwapOption
- type TextContent
Constants ¶
const RequestContextKey = "htmgo.request.context"
Variables ¶
var Version = uuid.NewString()
Functions ¶
func BaseExtensions ¶
func BaseExtensions() string
func Cached ¶
func Cached(duration time.Duration, cb GetElementFunc) func() *Element
Cached caches the given element for the given duration. The element is only rendered once, and then cached for the given duration. Please note this element is globally cached, and not per unique identifier / user. Use CachedPerKey to cache elements per unqiue identifier.
func CachedPerKey ¶
func CachedPerKey[K comparable](duration time.Duration, cb GetElementFuncWithKey[K]) func() *Element
CachedPerKey caches the given element for the given duration. The element is only rendered once per key, and then cached for the given duration. The element is cached by the unique identifier that is returned by the callback function.
func CachedPerKeyT ¶
func CachedPerKeyT[K comparable, T any](duration time.Duration, cb GetElementFuncTWithKey[K, T]) func(T) *Element
CachedPerKeyT caches the given element for the given duration. The element is only rendered once per key, and then cached for the given duration. The element is cached by the unique identifier that is returned by the callback function.
func CachedPerKeyT2 ¶
func CachedPerKeyT2[K comparable, T any, T2 any](duration time.Duration, cb GetElementFuncT2WithKey[K, T, T2]) func(T, T2) *Element
CachedPerKeyT2 caches the given element for the given duration. The element is only rendered once per key, and then cached for the given duration. The element is cached by the unique identifier that is returned by the callback function.
func CachedPerKeyT3 ¶
func CachedPerKeyT3[K comparable, T any, T2 any, T3 any](duration time.Duration, cb GetElementFuncT3WithKey[K, T, T2, T3]) func(T, T2, T3) *Element
CachedPerKeyT3 caches the given element for the given duration. The element is only rendered once per key, and then cached for the given duration. The element is cached by the unique identifier that is returned by the callback function.
func CachedPerKeyT4 ¶
func CachedPerKeyT4[K comparable, T any, T2 any, T3 any, T4 any](duration time.Duration, cb GetElementFuncT4WithKey[K, T, T2, T3, T4]) func(T, T2, T3, T4) *Element
CachedPerKeyT4 caches the given element for the given duration. The element is only rendered once per key, and then cached for the given duration. The element is cached by the unique identifier that is returned by the callback function.
func CachedT ¶
func CachedT[T any](duration time.Duration, cb GetElementFuncT[T]) func(T) *Element
CachedT caches the given element for the given duration. The element is only rendered once, and then cached for the given duration. Please note this element is globally cached, and not per unique identifier / user. Use CachedPerKey to cache elements per unqiue identifier.
func CachedT2 ¶
func CachedT2[T any, T2 any](duration time.Duration, cb GetElementFuncT2[T, T2]) func(T, T2) *Element
CachedT2 caches the given element for the given duration. The element is only rendered once, and then cached for the given duration. Please note this element is globally cached, and not per unique identifier / user. Use CachedPerKey to cache elements per unqiue identifier.
func CachedT3 ¶
func CachedT3[T any, T2 any, T3 any](duration time.Duration, cb GetElementFuncT3[T, T2, T3]) func(T, T2, T3) *Element
CachedT3 caches the given element for the given duration. The element is only rendered once, and then cached for the given duration. Please note this element is globally cached, and not per unique identifier / user. Use CachedPerKey to cache elements per unqiue identifier.
func CachedT4 ¶
func CachedT4[T any, T2 any, T3 any, T4 any](duration time.Duration, cb GetElementFuncT4[T, T2, T3, T4]) func(T, T2, T3, T4) *Element
CachedT4 caches the given element for the given duration. The element is only rendered once, and then cached for the given duration. Please note this element is globally cached, and not per unique identifier / user. Use CachedPerKey to cache elements per unqiue identifier.
func CombineCommands ¶ added in v1.0.5
func CurrentPath ¶
func CurrentPath(ctx *RequestContext) string
func GetLogLevel ¶
func GetPartialPath ¶
func GetPartialPath(partial PartialFunc) string
func GetPartialPathWithQs ¶
func GetPartialPathWithQs(partial func(ctx *RequestContext) *Partial, qs *Qs) string
func GetQueryParam ¶
func GetQueryParam(ctx *RequestContext, key string) string
GetQueryParam returns the value of the given query parameter from the request URL. There are two layers of priority: 1. The query parameter in the URL 2. The current browser URL If the query parameter is not found in the URL from the *RequestContext, it will fall back to the current browser URL if set. The URL from the *RequestContext would normally be the url from an XHR request through htmx, which is not the current browser url a visitor may be on.
func GroupBy ¶ added in v1.0.5
func GroupBy[T any, K comparable](slice []T, key func(item T) K) map[K][]T
GroupBy groups the items in the slice by the key returned by the key function.
func GroupByOrdered ¶ added in v1.0.5
func GroupByOrdered[T any, K comparable](slice []T, key func(item T) K) *orderedmap.Map[K, []T]
GroupByOrdered groups the items in the slice by the key returned by the key function, and returns an Map.
func IfElseLazy ¶
IfElseLazy returns node if condition is true, otherwise returns the result of cb2 This is useful if you want to lazily evaluate a node based on a condition For example, If you are rendering a component that requires specific data, you can use this to only load the component if the data is available
func IsDevelopment ¶
func IsDevelopment() bool
func IsEmptyPartial ¶ added in v1.0.5
func IsProduction ¶
func IsProduction() bool
func IsWatchMode ¶
func IsWatchMode() bool
func JsonSerializeOrEmpty ¶
JsonSerializeOrEmpty serializes the given data as JSON, or returns an empty string if the serialization fails.
func Map ¶
func Map[T, U any](slice []T, mapper func(item T) U) []U
Map returns a new slice with the results of the mapper function.
func MergeClasses ¶
MergeClasses merges multiple classes into a single class string
func MultiLineQuotes ¶
func PartialView ¶
func PartialView(w http.ResponseWriter, partial *Partial) error
func PartialViewWithHeaders ¶
func PartialViewWithHeaders(w http.ResponseWriter, headers *Headers, partial *Partial) error
func SetQueryParams ¶
SetQueryParams sets the query parameters of the given URL. Given the *Qs passed in, it will set the query parameters of the URL to the given values. If the value does not exist in *QS, it will remain untouched. If the value is an empty string, it will be removed from the query parameters. If the value is not an empty string, it will be set to the given value.
Types ¶
type App ¶
type App struct { Opts AppOpts Router *chi.Mux }
func (*App) AddLiveReloadHandler ¶
func (*App) Use ¶ added in v1.0.5
func (app *App) Use(h func(ctx *RequestContext))
func (*App) UseWithContext ¶
type AttributeMap ¶
type AttributeMapOrdered ¶
type AttributeMapOrdered struct {
// contains filtered or unexported fields
}
func AttributeList ¶
func AttributeList(children ...*AttributeR) *AttributeMapOrdered
func AttributePairs ¶
func AttributePairs(pairs ...string) *AttributeMapOrdered
func Attributes ¶
func Attributes(attributes *AttributeMap) *AttributeMapOrdered
func Get ¶
func Get(path string, trigger ...string) *AttributeMapOrdered
Get adds two attributes to the element: hx-get and hx-trigger.
func GetPartial ¶
func GetPartial(partial PartialFunc, trigger ...string) *AttributeMapOrdered
GetPartial adds two attributes to the element: hx-get and hx-trigger, and uses the partial path for the hx-get attribute.
func GetPartialWithQs ¶
func GetPartialWithQs(partial PartialFunc, qs *Qs, trigger string) *AttributeMapOrdered
GetPartialWithQs adds two attributes to the element: hx-get and hx-trigger, and uses the partial path for the hx-get attribute. It also sets the query string parameters.
func GetWithQs ¶
func GetWithQs(path string, qs *Qs, trigger string) *AttributeMapOrdered
GetWithQs adds two attributes to the element: hx-get and hx-trigger, and uses the path for the hx-get attribute. It also sets the query string parameters.
func NewAttributeMap ¶
func NewAttributeMap(pairs ...string) *AttributeMapOrdered
func Post ¶
func Post(url string, trigger ...string) *AttributeMapOrdered
func PostOnClick ¶
func PostOnClick(url string) *AttributeMapOrdered
PostOnClick adds two attributes to the element: hx-post and hx-trigger, and uses the path for the hx-post attribute. It also sets the hx-trigger to hx-click.
func PostPartial ¶
func PostPartial(partial PartialFunc, triggers ...string) *AttributeMapOrdered
PostPartial adds two attributes to the element: hx-post and hx-trigger, and uses the partial path for the hx-post attribute.
func PostPartialOnClick ¶
func PostPartialOnClick(partial PartialFunc) *AttributeMapOrdered
PostPartialOnClick adds two attributes to the element: hx-post and hx-trigger, and uses the partial path for the hx-post attribute. It also sets the hx-trigger to hx-click.
func PostPartialOnClickQs ¶
func PostPartialOnClickQs(partial PartialFunc, qs *Qs) *AttributeMapOrdered
PostPartialOnClickQs adds two attributes to the element: hx-post and hx-trigger, and uses the partial path for the hx-post attribute. It also sets the hx-trigger to hx-click. It also sets the query string parameters.
func PostPartialWithQs ¶
func PostPartialWithQs(partial PartialFunc, qs *Qs, trigger ...string) *AttributeMapOrdered
PostPartialWithQs adds two attributes to the element: hx-post and hx-trigger, and uses the partial path for the hx-post attribute. It also sets the query string parameters.
func PostWithQs ¶
func PostWithQs(url string, qs *Qs, trigger string) *AttributeMapOrdered
PostWithQs adds two attributes to the element: hx-post and hx-trigger, and uses the path for the hx-post attribute. It also sets the query string parameters.
func (*AttributeMapOrdered) Each ¶
func (m *AttributeMapOrdered) Each(cb func(key string, value string))
func (*AttributeMapOrdered) Entries ¶
func (m *AttributeMapOrdered) Entries() []orderedmap.Entry[string, string]
func (*AttributeMapOrdered) Render ¶
func (m *AttributeMapOrdered) Render(context *RenderContext)
func (*AttributeMapOrdered) Set ¶
func (m *AttributeMapOrdered) Set(key string, value any)
type AttributeR ¶
func Action ¶
func Action(value string) *AttributeR
func AriaHidden ¶
func AriaHidden(value bool) *AttributeR
func AriaLabel ¶
func AriaLabel(value string) *AttributeR
func Attribute ¶
func Attribute(key string, value string) *AttributeR
func AutoComplete ¶
func AutoComplete(value string) *AttributeR
func AutoFocus ¶
func AutoFocus() *AttributeR
func Class ¶
func Class(value ...string) *AttributeR
func ClassF ¶ added in v1.0.1
func ClassF(format string, args ...interface{}) *AttributeR
ClassF is a helper function to create a class attribute with the given format string and arguments
func Cols ¶
func Cols(value int) *AttributeR
func Disabled ¶
func Disabled() *AttributeR
func Download ¶
func Download(value bool) *AttributeR
func Enctype ¶
func Enctype(value string) *AttributeR
func Height ¶
func Height(value int) *AttributeR
func HxExtension ¶
func HxExtension(value string) *AttributeR
HxExtension Adds a hx-ext to an element
func HxIndicator ¶
func HxIndicator(tag string) *AttributeR
func HxTrigger ¶
func HxTrigger(opts ...hx.TriggerEvent) *AttributeR
HxTrigger Adds a hx-trigger to an element
func HxTriggerClick ¶
func HxTriggerClick(opts ...hx.Modifier) *AttributeR
HxTriggerClick Adds a hx-trigger="click" to an element
func HxTriggerString ¶
func HxTriggerString(triggers ...string) *AttributeR
HxTriggerString Adds a hx-trigger to an element based on a string of triggers
func JoinAttributes ¶
func JoinAttributes(sep string, attrs ...*AttributeR) *AttributeR
JoinAttributes joins multiple attributes into a single attribute string based on a separator Example: JoinAttributes(", ", Attribute("hx-extension", "one"), Attribute("hx-extension", "two")) = hx-extension="one,two"
func Max ¶
func Max(value string) *AttributeR
func MaxLength ¶
func MaxLength(value int) *AttributeR
func Method ¶
func Method(value string) *AttributeR
func Min ¶
func Min(value string) *AttributeR
func MinLength ¶
func MinLength(value int) *AttributeR
func Multiple ¶
func Multiple() *AttributeR
func NewAttribute ¶
func NewAttribute(name string, value string) *AttributeR
func NoSwap ¶
func NoSwap() *AttributeR
func NoValidate ¶
func NoValidate() *AttributeR
func Pattern ¶
func Pattern(value string) *AttributeR
func ReadOnly ¶
func ReadOnly() *AttributeR
func Rel ¶
func Rel(value string) *AttributeR
func Required ¶
func Required() *AttributeR
func Role ¶
func Role(value string) *AttributeR
func Rows ¶
func Rows(value int) *AttributeR
func Selected ¶
func Selected() *AttributeR
func Size ¶
func Size(value int) *AttributeR
func Src ¶
func Src(src string) *AttributeR
func Step ¶
func Step(value string) *AttributeR
func TabIndex ¶
func TabIndex(value int) *AttributeR
func TriggerChildren ¶
func TriggerChildren() *AttributeR
TriggerChildren Adds the hx-extension="trigger-children" to an element See https://htmgo.dev/docs#htmx-extensions-trigger-children
func Value ¶
func Value(value any) *AttributeR
func Width ¶
func Width(value int) *AttributeR
func Wrap ¶
func Wrap(value string) *AttributeR
func (*AttributeR) Render ¶
func (a *AttributeR) Render(context *RenderContext)
type ByKeyEntry ¶
type ByKeyEntry struct {
// contains filtered or unexported fields
}
func (*ByKeyEntry) Render ¶
func (c *ByKeyEntry) Render(ctx *RenderContext)
type CachedNode ¶
type CachedNode struct {
// contains filtered or unexported fields
}
func (*CachedNode) ClearCache ¶
func (c *CachedNode) ClearCache()
ClearCache clears the cached HTML of the element. This is called automatically by the framework.
func (*CachedNode) ClearExpired ¶
func (c *CachedNode) ClearExpired()
ClearExpired clears all expired cached HTML of the element. This is called automatically by the framework.
func (*CachedNode) Render ¶
func (c *CachedNode) Render(ctx *RenderContext)
type ChildList ¶
type ChildList struct {
Children []Ren
}
func NewChildList ¶
func (*ChildList) Render ¶
func (c *ChildList) Render(context *RenderContext)
type Command ¶
type Command = Ren
func ToggleText ¶ added in v1.0.5
ToggleText toggles the given text on the element.
func ToggleTextOnChildren ¶ added in v1.0.5
ToggleTextOnChildren toggles the given text on the children of the element.
func ToggleTextOnParent ¶ added in v1.0.5
ToggleTextOnParent toggles the given text on the parent of the element.
func ToggleTextOnSibling ¶ added in v1.0.5
ToggleTextOnSibling toggles the given text on the siblings of the element.
type ComplexJsCommand ¶
func EvalCommands ¶ added in v1.0.5
func EvalCommands(element *Element, cmds ...Command) ComplexJsCommand
func EvalCommandsOnSelector ¶ added in v1.0.5
func EvalCommandsOnSelector(selector string, cmds ...Command) ComplexJsCommand
func EvalJsOnChildren ¶
func EvalJsOnChildren(selector, js string) ComplexJsCommand
EvalJsOnChildren evaluates the given JavaScript code on the children of the element. Reference the element using 'element'.
func EvalJsOnParent ¶
func EvalJsOnParent(js string) ComplexJsCommand
EvalJsOnParent evaluates the given JavaScript code on the parent of the element. Reference the element using 'element'.
func EvalJsOnSibling ¶
func EvalJsOnSibling(selector, js string) ComplexJsCommand
EvalJsOnSibling evaluates the given JavaScript code on the siblings of the element. Reference the element using 'element'.
func InjectScript ¶
func InjectScript(src string) ComplexJsCommand
InjectScript injects a script tag into the document.
func InjectScriptIfNotExist ¶
func InjectScriptIfNotExist(src string) ComplexJsCommand
InjectScriptIfNotExist injects a script tag into the document if it does not already exist.
func NewComplexJsCommand ¶
func NewComplexJsCommand(command string) ComplexJsCommand
NewComplexJsCommand creates a new complex JavaScript command.
func RemoveClassOnChildren ¶
func RemoveClassOnChildren(selector, class string) ComplexJsCommand
RemoveClassOnChildren removes the given class from the children of the element. Reference the element using 'element'.
func RemoveClassOnParent ¶
func RemoveClassOnParent(class string) ComplexJsCommand
RemoveClassOnParent removes the given class from the parent of the element.
func RemoveClassOnSibling ¶
func RemoveClassOnSibling(selector, class string) ComplexJsCommand
RemoveClassOnSibling removes the given class from the siblings of the element. Reference the element using 'element'.
func RunAfterTimeout ¶ added in v1.0.5
func RunAfterTimeout(time time.Duration, cmds ...Command) ComplexJsCommand
func RunOnInterval ¶ added in v1.0.5
func RunOnInterval(time time.Duration, cmds ...Command) ComplexJsCommand
func SetClassOnChildren ¶
func SetClassOnChildren(selector, class string) ComplexJsCommand
SetClassOnChildren sets the given class on the children of the element.
func SetClassOnParent ¶
func SetClassOnParent(class string) ComplexJsCommand
SetClassOnParent sets the given class on the parent of the element.
func SetClassOnSibling ¶
func SetClassOnSibling(selector, class string) ComplexJsCommand
SetClassOnSibling sets the given class on the siblings of the element. Reference the element using 'element'.
func SetTextOnChildren ¶
func SetTextOnChildren(selector, text string) ComplexJsCommand
SetTextOnChildren sets the inner text of all the children of the element that match the selector.
func SubmitFormOnEnter ¶
func SubmitFormOnEnter() ComplexJsCommand
SubmitFormOnEnter submits the form when the user presses the enter key.
func ToggleClassOnChildren ¶ added in v1.0.5
func ToggleClassOnChildren(selector, class string) ComplexJsCommand
ToggleClassOnChildren toggles the given class on the children of the element.
func ToggleClassOnElement ¶
func ToggleClassOnElement(selector, class string) ComplexJsCommand
ToggleClassOnElement toggles the given class on the elements returned by the selector.
func ToggleClassOnParent ¶ added in v1.0.5
func ToggleClassOnParent(class string) ComplexJsCommand
ToggleClassOnParent toggles the given class on the parent of the element.
func ToggleClassOnSibling ¶ added in v1.0.5
func ToggleClassOnSibling(selector, class string) ComplexJsCommand
ToggleClassOnSibling toggles the given class on the siblings of the element.
func (ComplexJsCommand) Render ¶
func (j ComplexJsCommand) Render(context *RenderContext)
type CustomElement ¶
type CustomElement = string
var ( CachedNodeTag CustomElement = "htmgo_cache_node" CachedNodeByKeyEntry CustomElement = "htmgo_cached_node_by_key_entry" )
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
func AppendChildren ¶
func ElementIf ¶
ElementIf returns the element if the condition is true, otherwise returns an empty element
func NumberInput ¶
func OobSwap ¶
func OobSwap(ctx *RequestContext, content *Element, option ...SwapOption) *Element
func OobSwapWithSelector ¶
func OobSwapWithSelector(ctx *RequestContext, selector string, content *Element, option ...SwapOption) *Element
func ScriptWithVersion ¶
func SwapMany ¶
func SwapMany(ctx *RequestContext, elements ...*Element) *Element
func SwapManyX ¶
func SwapManyX(ctx *RequestContext, args ...SwapArg) *Element
func (*Element) AppendChild ¶
func (*Element) AppendChildren ¶
func (*Element) Render ¶
func (node *Element) Render(context *RenderContext)
type GetElementFunc ¶
type GetElementFunc func() *Element
type GetElementFuncT ¶
type GetElementFuncT2 ¶
type GetElementFuncT2WithKey ¶
type GetElementFuncT2WithKey[K comparable, T any, T2 any] func(T, T2) (K, GetElementFunc)
type GetElementFuncT3WithKey ¶
type GetElementFuncT3WithKey[K comparable, T any, T2 any, T3 any] func(T, T2, T3) (K, GetElementFunc)
type GetElementFuncT4 ¶
type GetElementFuncT4WithKey ¶
type GetElementFuncT4WithKey[K comparable, T any, T2 any, T3 any, T4 any] func(T, T2, T3, T4) (K, GetElementFunc)
type GetElementFuncTWithKey ¶
type GetElementFuncTWithKey[K comparable, T any] func(T) (K, GetElementFunc)
type GetElementFuncWithKey ¶
type GetElementFuncWithKey[K comparable] func() (K, GetElementFunc)
type Headers ¶
func CombineHeaders ¶
func NewHeaders ¶
func PushQsHeader ¶
func PushQsHeader(ctx *RequestContext, qs *Qs) *Headers
func PushUrlHeader ¶
func ReplaceUrlHeader ¶
type LifeCycle ¶
type LifeCycle struct {
// contains filtered or unexported fields
}
func HxAfterRequest ¶
HxAfterRequest executes the given commands after the request is sent.
func HxAfterSseMessage ¶
HxAfterSseMessage executes the given commands when a message is received from the server via SSE, and after it is processed.
func HxBeforeRequest ¶
HxBeforeRequest executes the given commands before the request is sent.
func HxBeforeSseMessage ¶
HxBeforeSseMessage executes the given commands when a message is received from the server via SSE, but before it is processed.
func HxOnAfterSwap ¶
HxOnAfterSwap executes the given commands when the element is swapped in.
func HxOnLoad ¶
HxOnLoad executes the given commands when the element is loaded into the DOM. Deprecated: Use OnLoad instead.
func HxOnMutationError ¶
HxOnMutationError executes the given commands when a mutation error of a request occurs.
func HxOnSseClose ¶
HxOnSseClose executes the given commands when the connection to the server via SSE is closed.
func HxOnSseConnecting ¶
HxOnSseConnecting executes the given commands when the connection to the server via SSE is being established.
func HxOnSseError ¶
HxOnSseError executes the given commands when an error occurs while connecting to the server via SSE.
func HxOnSseOpen ¶
HxOnSseOpen executes the given commands when the connection to the server via SSE is established.
func NewLifeCycle ¶
func NewLifeCycle() *LifeCycle
func OnLoad ¶
OnLoad executes the given commands when the element is loaded into the DOM, it also executes when the element is replaced / swapped in. This will work on any element because of the htmgo htmx extension to trigger it, instead of the browser.
func (*LifeCycle) HxAfterRequest ¶
func (*LifeCycle) HxBeforeRequest ¶
func (*LifeCycle) HxOnMutationError ¶
func (*LifeCycle) Render ¶
func (l *LifeCycle) Render(context *RenderContext)
type Page ¶
func NewPageWithHttpMethod ¶
type Partial ¶
func EmptyPartial ¶
func EmptyPartial() *Partial
func NewPartial ¶
func NewPartialWithHeaders ¶
func RedirectPartial ¶
func SwapManyPartial ¶
func SwapManyPartial(ctx *RequestContext, swaps ...*Element) *Partial
func SwapManyPartialWithHeaders ¶
func SwapManyPartialWithHeaders(ctx *RequestContext, headers *Headers, swaps ...*Element) *Partial
func SwapManyXPartial ¶
func SwapManyXPartial(ctx *RequestContext, swaps ...SwapArg) *Partial
func SwapPartial ¶
func SwapPartial(ctx *RequestContext, swap *Element) *Partial
func (*Partial) Render ¶
func (p *Partial) Render(context *RenderContext)
type PartialFunc ¶
type PartialFunc = func(ctx *RequestContext) *Partial
type RawContent ¶
type RawContent struct {
Content string
}
func NewRawContent ¶
func NewRawContent(content string) *RawContent
func UnsafeRaw ¶
func UnsafeRaw(text string) *RawContent
UnsafeRaw is a helper function to create a raw content with the given text The text is not escaped, do not use this function with user input
func UnsafeRawF ¶
func UnsafeRawF(text string, args any) *RawContent
UnsafeRawF is a helper function to create a raw content with the given text The text is not escaped, do not use this function with user input
func UnsafeRawScript ¶
func UnsafeRawScript(text string) *RawContent
UnsafeRawScript is a helper function to create a script tag with the given text The text is not escaped, do not use this function with user input
func (*RawContent) Render ¶
func (r *RawContent) Render(context *RenderContext)
type Ren ¶
type Ren interface {
Render(context *RenderContext)
}
func AttributeIf ¶
AttributeIf returns the attribute if the condition is true, otherwise returns an empty element
func ClassIf ¶
ClassIf returns the class attribute if the condition is true, otherwise returns an empty element
func ClassX ¶
ClassX conditionally renders a class based on a map of class names and boolean values value is any non-conditional class name you'd like to add m is a map of class names and boolean values
func HxExtensions ¶
HxExtensions Adds multiple hx-ext to an element, separated by commas
func HxInclude ¶
HxInclude https://htmx.org/attributes/hx-include/
func IfHtmxRequest ¶
func IfHtmxRequest(ctx *RequestContext, node Ren) Ren
IfHtmxRequest returns the node if the request is an htmx request, otherwise returns an empty element
func IfQueryParam ¶
func JoinExtensions ¶
func JoinExtensions(attrs ...*AttributeR) Ren
func Placeholder ¶
type RenderContext ¶
type RenderContext struct {
// contains filtered or unexported fields
}
func (*RenderContext) AddScript ¶
func (ctx *RenderContext) AddScript(funcName string, body string)
type RenderOpt ¶ added in v1.0.1
type RenderOpt func(context *RenderContext, opt *RenderOptions)
func WithDocType ¶ added in v1.0.1
func WithDocType() RenderOpt
type RenderOptions ¶ added in v1.0.1
type RenderOptions struct {
// contains filtered or unexported fields
}
type RequestContext ¶
type RequestContext struct { Request *http.Request Response http.ResponseWriter // contains filtered or unexported fields }
func GetRequestContext ¶
func GetRequestContext(r *http.Request) *RequestContext
func (*RequestContext) FormValue ¶
func (c *RequestContext) FormValue(key string) string
func (*RequestContext) Get ¶
func (c *RequestContext) Get(key string) interface{}
func (*RequestContext) Header ¶
func (c *RequestContext) Header(key string) string
func (*RequestContext) HxCurrentBrowserUrl ¶
func (c *RequestContext) HxCurrentBrowserUrl() string
func (*RequestContext) HxPromptResponse ¶
func (c *RequestContext) HxPromptResponse() string
func (*RequestContext) HxTargetId ¶
func (c *RequestContext) HxTargetId() string
func (*RequestContext) HxTriggerId ¶
func (c *RequestContext) HxTriggerId() string
func (*RequestContext) HxTriggerName ¶
func (c *RequestContext) HxTriggerName() string
func (*RequestContext) IsBoosted ¶
func (c *RequestContext) IsBoosted() bool
func (*RequestContext) IsHttpDelete ¶
func (c *RequestContext) IsHttpDelete() bool
func (*RequestContext) IsHttpGet ¶
func (c *RequestContext) IsHttpGet() bool
func (*RequestContext) IsHttpPost ¶
func (c *RequestContext) IsHttpPost() bool
func (*RequestContext) IsHttpPut ¶
func (c *RequestContext) IsHttpPut() bool
func (*RequestContext) IsHxRequest ¶
func (c *RequestContext) IsHxRequest() bool
func (*RequestContext) QueryParam ¶
func (c *RequestContext) QueryParam(key string) string
func (*RequestContext) Redirect ¶
func (c *RequestContext) Redirect(path string, code int)
func (*RequestContext) ServiceLocator ¶
func (c *RequestContext) ServiceLocator() *service.Locator
ServiceLocator returns the service locator to register and retrieve services Usage: service.Set[db.Queries](locator, service.Singleton, db.Provide) service.Get[db.Queries](locator)
func (*RequestContext) Set ¶
func (c *RequestContext) Set(key string, value interface{})
func (*RequestContext) SetCookie ¶
func (c *RequestContext) SetCookie(cookie *http.Cookie)
func (*RequestContext) UrlParam ¶
func (c *RequestContext) UrlParam(key string) string
type ScriptEntry ¶ added in v1.0.5
type SimpleJsCommand ¶
type SimpleJsCommand struct {
Command string
}
func AddAttribute ¶
func AddAttribute(name, value string) SimpleJsCommand
AddAttribute adds the given attribute to the element.
func AddClass ¶
func AddClass(class string) SimpleJsCommand
AddClass adds the given class to the element.
func Alert ¶
func Alert(text string) SimpleJsCommand
Alert displays an alert dialog with the given text.
func ConsoleLog ¶
func ConsoleLog(text string) SimpleJsCommand
ConsoleLog logs a message to the console.
func Increment ¶
func Increment(amount int) SimpleJsCommand
Increment increments the inner text of the element by the given amount.
func PreventDefault ¶
func PreventDefault() SimpleJsCommand
PreventDefault prevents the default action of the event.
func RemoveAttribute ¶
func RemoveAttribute(name string) SimpleJsCommand
RemoveAttribute removes the given attribute from the element.
func RemoveClass ¶
func RemoveClass(class string) SimpleJsCommand
RemoveClass removes the given class from the element.
func SetDisabled ¶
func SetDisabled(disabled bool) SimpleJsCommand
SetDisabled sets the disabled attribute on the element.
func SetInnerHtml ¶
func SetInnerHtml(r Ren) SimpleJsCommand
SetInnerHtml sets the inner HTML of the element.
func SetOuterHtml ¶
func SetOuterHtml(r Ren) SimpleJsCommand
SetOuterHtml sets the outer HTML of the element.
func SetText ¶
func SetText(text string) SimpleJsCommand
SetText sets the inner text of the element.
func ToggleClass ¶
func ToggleClass(class string) SimpleJsCommand
ToggleClass toggles the given class on the element.
func (SimpleJsCommand) Render ¶
func (j SimpleJsCommand) Render(context *RenderContext)
type SwapArg ¶
type SwapArg struct { Content *Element Option SwapOption }
func NewSwap ¶
func NewSwap(content *Element, opts ...SwapOption) SwapArg
type TextContent ¶
type TextContent struct {
Content string
}
func NewTextContent ¶
func NewTextContent(content string) *TextContent
func Text ¶
func Text(text string) *TextContent
func TextF ¶
func TextF(format string, args ...interface{}) *TextContent
func (*TextContent) Render ¶
func (t *TextContent) Render(context *RenderContext)