Documentation
¶
Index ¶
- func Case[T comparable](match T, element Element) any
- func Default(element Element) any
- func EscapeString(s string) string
- type DefaultElement
- func (e *DefaultElement) Action(action string) Element
- func (e *DefaultElement) Add(elements ...Element) Element
- func (e *DefaultElement) AddChild(child Element) Element
- func (e *DefaultElement) Alt(alt string) Element
- func (e *DefaultElement) AtClick(handler string) Element
- func (e *DefaultElement) Attr(key string, value ...string) Element
- func (e *DefaultElement) ChildWithId(id string) (Element, bool)
- func (e *DefaultElement) Children(elements ...Element) Element
- func (e *DefaultElement) Class(classes ...string) Element
- func (e *DefaultElement) Defer(value ...bool) Element
- func (e *DefaultElement) For(value string) Element
- func (e *DefaultElement) GetAttr(key string) string
- func (e *DefaultElement) GetAttrs() map[string]string
- func (e *DefaultElement) GetChild(idx int) (Element, bool)
- func (e *DefaultElement) GetChildren() []Element
- func (e *DefaultElement) GetChildrenWithClass(class string) []Element
- func (e *DefaultElement) GetClasses() []string
- func (e *DefaultElement) GetContent() string
- func (e *DefaultElement) GetFirstChildWithClass(class string) (Element, bool)
- func (e *DefaultElement) GetId() string
- func (e *DefaultElement) GetNthChildWithClass(class string, n int) (Element, bool)
- func (e *DefaultElement) GetStyle(key string) string
- func (e *DefaultElement) GetStyles() map[string]string
- func (e *DefaultElement) GetTag() string
- func (e *DefaultElement) HXBoost(boost ...bool) Element
- func (e *DefaultElement) HXConfirm(prompt string) Element
- func (e *DefaultElement) HXDelete(url string) Element
- func (e *DefaultElement) HXGet(url string) Element
- func (e *DefaultElement) HXHistory(history string) Element
- func (e *DefaultElement) HXInclude(selector string) Element
- func (e *DefaultElement) HXIndicator(indicator string) Element
- func (e *DefaultElement) HXOn(event string, script string) Element
- func (e *DefaultElement) HXOob(oob string) Element
- func (e *DefaultElement) HXPatch(url string) Element
- func (e *DefaultElement) HXPost(url string) Element
- func (e *DefaultElement) HXPushUrl(pushUrl string) Element
- func (e *DefaultElement) HXPut(url string) Element
- func (e *DefaultElement) HXReplaceUrl(replaceUrl string) Element
- func (e *DefaultElement) HXSelect(value string) Element
- func (e *DefaultElement) HXSwap(value string) Element
- func (e *DefaultElement) HXSwapOob(oob string) Element
- func (e *DefaultElement) HXTarget(target string) Element
- func (e *DefaultElement) HXTrigger(trigger string) Element
- func (e *DefaultElement) HXVals(json string) Element
- func (e *DefaultElement) HasClass(class string) bool
- func (e *DefaultElement) Href(href string) Element
- func (e *DefaultElement) Id(value string) Element
- func (e *DefaultElement) Method(method string) Element
- func (e *DefaultElement) Name(name string) Element
- func (e *DefaultElement) OnClick(value string) Element
- func (e *DefaultElement) OobOnly(w http.ResponseWriter)
- func (e *DefaultElement) Placeholder(placeholder string) Element
- func (e *DefaultElement) Prepend(elements ...Element) Element
- func (e *DefaultElement) PrependChild(child Element) Element
- func (e *DefaultElement) RemoveAttr(keys ...string) Element
- func (e *DefaultElement) RemoveClass(classes ...string) Element
- func (e *DefaultElement) RemoveStyle(styles ...string) Element
- func (e *DefaultElement) Render() string
- func (e *DefaultElement) RenderWithContent(text string, children ...Element) string
- func (e *DefaultElement) Send(w http.ResponseWriter)
- func (e *DefaultElement) Src(src string) Element
- func (e *DefaultElement) Style(style string) Element
- func (e *DefaultElement) Submit() Element
- func (e *DefaultElement) Tag(tag string) Element
- func (e *DefaultElement) Text(content string) Element
- func (e *DefaultElement) Title(title string) Element
- func (e *DefaultElement) Type(tipe string) Element
- func (e *DefaultElement) UnsafeHtml(content string) Element
- func (e *DefaultElement) Value(value string) Element
- func (e *DefaultElement) XBind(attr string, value string) Element
- func (e *DefaultElement) XCloak() Element
- func (e *DefaultElement) XData(data string) Element
- func (e *DefaultElement) XHtml(value string) Element
- func (e *DefaultElement) XInit(value string) Element
- func (e *DefaultElement) XModel(value string) Element
- func (e *DefaultElement) XOn(event string, value string) Element
- func (e *DefaultElement) XRef(value string) Element
- func (e *DefaultElement) XShow(condition string) Element
- func (e *DefaultElement) XText(value string) Element
- type Element
- func A(href string, children ...Element) Element
- func Body(children ...Element) Element
- func Button(text string) Element
- func CheckboxGroup(name string, value string, options []Option) Element
- func Div(class string, children ...Element) Element
- func For[T any](objs []T, element func(T, int) Element) Element
- func Form(children ...Element) Element
- func Fragment(children ...Element) Element
- func FromHtml(s string) (Element, error)
- func H1(text string) Element
- func H2(text string) Element
- func H3(text string) Element
- func H4(text string) Element
- func H5(text string) Element
- func H6(text string) Element
- func Head(children ...Element) Element
- func HiddenInput(name string, value string) Element
- func Html(content string) Element
- func If(condition bool, children ...Element) Element
- func IfElse(condition bool, ifElement Element, elseElement ...Element) Element
- func Img(src string) Element
- func Input(name string) Element
- func Label(text string) Element
- func Li(children ...Element) Element
- func List[T any](data []T, rowFunc ...func(T, int) Element) Element
- func NewElement(tag string) Element
- func None() Element
- func P(text string) Element
- func Picture(alt string, sources ...PictureSource) Element
- func RadioGroup(name string, value string, options []Option) Element
- func Script(js string) Element
- func Section(children ...Element) Element
- func Span(text string) Element
- func String(text string) Element
- func Style(css string) Element
- func Stylesheet(url string) Element
- func Switch[T comparable](value T, items ...any) Element
- func Table(children ...Element) Element
- func Td(children ...Element) Element
- func Template(children ...Element) Element
- func Th(children ...Element) Element
- func Title(text string) Element
- func Tr(children ...Element) Element
- func Ul(children ...Element) Element
- func VideoIframe(title string, width int, height int, src string) Element
- type Field
- func Checkbox(name, label, value string) *Field
- func HiddenField(name, label, value string) *Field
- func NewField(name, label, value, tipe string) *Field
- func Radio(name, label, value string) *Field
- func Select(name, label, value string, options []Option, ...) *Field
- func TextField(name, label, value string) *Field
- func Textarea(name, label, value string) *Field
- type Option
- type PictureSource
- type SvgCircle
- func (t *SvgCircle) At(x, y int) *SvgCircle
- func (t *SvgCircle) CenterX(x int) *SvgCircle
- func (t *SvgCircle) CenterY(y int) *SvgCircle
- func (t *SvgCircle) Fill(color string) *SvgCircle
- func (t *SvgCircle) FillOpacity(opacity float64) *SvgCircle
- func (t *SvgCircle) Filter(filter string) *SvgCircle
- func (t *SvgCircle) Opacity(opacity float64) *SvgCircle
- func (t *SvgCircle) Radius(radius int) *SvgCircle
- func (t *SvgCircle) Stroke(color string) *SvgCircle
- func (t *SvgCircle) StrokeDasharray(dasharray string) *SvgCircle
- func (t *SvgCircle) StrokeLinecap(linecap string) *SvgCircle
- func (t *SvgCircle) StrokeLinejoin(linejoin string) *SvgCircle
- func (t *SvgCircle) StrokeMiterlimit(miterlimit float64) *SvgCircle
- func (t *SvgCircle) StrokeOpacity(opacity float64) *SvgCircle
- func (t *SvgCircle) StrokeWidth(width int) *SvgCircle
- type SvgElement
- func (s *SvgElement) D(d string) *SvgElement
- func (s *SvgElement) Height(height int) *SvgElement
- func (s *SvgElement) Version(version string) *SvgElement
- func (s *SvgElement) ViewBox(x, y, width, height int) *SvgElement
- func (s *SvgElement) Width(width int) *SvgElement
- func (s *SvgElement) Xmlns(xmlns string) *SvgElement
- func (s *SvgElement) XmlnsXlink(xmlnsXlink string) *SvgElement
- type SvgGroup
- type SvgImage
- func (i *SvgImage) At(x, y int) *SvgImage
- func (i *SvgImage) Height(height int) *SvgImage
- func (i *SvgImage) Href(href string) *SvgImage
- func (i *SvgImage) Size(width, height int) *SvgImage
- func (i *SvgImage) Width(width int) *SvgImage
- func (i *SvgImage) X(x int) *SvgImage
- func (i *SvgImage) Y(y int) *SvgImage
- type SvgLine
- func (t *SvgLine) Fill(color string) *SvgLine
- func (t *SvgLine) FillOpacity(opacity float64) *SvgLine
- func (t *SvgLine) From(x, y int) *SvgLine
- func (t *SvgLine) Opacity(opacity float64) *SvgLine
- func (t *SvgLine) Stroke(color string) *SvgLine
- func (t *SvgLine) StrokeDasharray(dasharray string) *SvgLine
- func (t *SvgLine) StrokeDashoffset(offset float64) *SvgLine
- func (t *SvgLine) StrokeLinecap(linecap string) *SvgLine
- func (t *SvgLine) StrokeLinejoin(linejoin string) *SvgLine
- func (t *SvgLine) StrokeMiterlimit(miterlimit float64) *SvgLine
- func (t *SvgLine) StrokeWidth(width float64) *SvgLine
- func (t *SvgLine) To(x, y int) *SvgLine
- type SvgPath
- func (p *SvgPath) ClipPath(clipPath string) *SvgPath
- func (p *SvgPath) D(d string) *SvgPath
- func (p *SvgPath) Fill(fill string) *SvgPath
- func (p *SvgPath) Filter(filter string) *SvgPath
- func (p *SvgPath) Opacity(opacity float64) *SvgPath
- func (p *SvgPath) PathLength(length float64) *SvgPath
- func (p *SvgPath) Stroke(stroke string) *SvgPath
- func (p *SvgPath) StrokeDasharray(dasharray string) *SvgPath
- func (p *SvgPath) StrokeDashoffset(offset float64) *SvgPath
- func (p *SvgPath) StrokeLinecap(linecap string) *SvgPath
- func (p *SvgPath) StrokeLinejoin(linejoin string) *SvgPath
- func (p *SvgPath) StrokeMiterlimit(miterlimit float64) *SvgPath
- func (p *SvgPath) StrokeWidth(width float64) *SvgPath
- func (p *SvgPath) Transform(transform string) *SvgPath
- type SvgRect
- func (t *SvgRect) ClipPath(clipPath string) *SvgRect
- func (t *SvgRect) Fill(color string) *SvgRect
- func (t *SvgRect) FillOpacity(opacity float64) *SvgRect
- func (t *SvgRect) Filter(filter string) *SvgRect
- func (t *SvgRect) Height(height int) *SvgRect
- func (t *SvgRect) Opacity(opacity float64) *SvgRect
- func (t *SvgRect) RX(rx int) *SvgRect
- func (t *SvgRect) RY(ry int) *SvgRect
- func (t *SvgRect) Stroke(color string) *SvgRect
- func (t *SvgRect) StrokeDasharray(dasharray string) *SvgRect
- func (t *SvgRect) StrokeLinecap(linecap string) *SvgRect
- func (t *SvgRect) StrokeLinejoin(linejoin string) *SvgRect
- func (t *SvgRect) StrokeMiterlimit(miterlimit float64) *SvgRect
- func (t *SvgRect) StrokeOpacity(opacity float64) *SvgRect
- func (t *SvgRect) StrokeWidth(width int) *SvgRect
- func (t *SvgRect) Transform(transform string) *SvgRect
- func (t *SvgRect) Width(width int) *SvgRect
- func (t *SvgRect) X(x int) *SvgRect
- func (t *SvgRect) Y(y int) *SvgRect
- type SvgText
- func (t *SvgText) AlignmentBaseline(baseline string) *SvgText
- func (t *SvgText) DominantBaseline(baseline string) *SvgText
- func (t *SvgText) Dx(dx float64) *SvgText
- func (t *SvgText) Dy(dy float64) *SvgText
- func (t *SvgText) Fill(color string) *SvgText
- func (t *SvgText) FontFamily(fontFamily string) *SvgText
- func (t *SvgText) FontSize(size int) *SvgText
- func (t *SvgText) FontSizeAdjust(sizeAdjust string) *SvgText
- func (t *SvgText) FontStyle(style string) *SvgText
- func (t *SvgText) FontWeight(weight string) *SvgText
- func (t *SvgText) LengthAdjust(lengthAdjust string) *SvgText
- func (t *SvgText) LetterSpacing(spacing float64) *SvgText
- func (t *SvgText) Rotate(angle float64) *SvgText
- func (t *SvgText) SetText(text string) *SvgText
- func (t *SvgText) Stroke(color string) *SvgText
- func (t *SvgText) StrokeDasharray(dasharray string) *SvgText
- func (t *SvgText) StrokeDashoffset(offset float64) *SvgText
- func (t *SvgText) StrokeLinecap(linecap string) *SvgText
- func (t *SvgText) StrokeLinejoin(linejoin string) *SvgText
- func (t *SvgText) StrokeMiterlimit(miterlimit float64) *SvgText
- func (t *SvgText) StrokeWidth(width float64) *SvgText
- func (t *SvgText) TextAnchor(anchor string) *SvgText
- func (t *SvgText) TextDecoration(decoration string) *SvgText
- func (t *SvgText) TextLength(length float64) *SvgText
- func (t *SvgText) TextPath(path string) *SvgText
- func (t *SvgText) Transform(transform string) *SvgText
- func (t *SvgText) WordSpacing(spacing float64) *SvgText
- func (t *SvgText) WritingMode(mode string) *SvgText
- func (t *SvgText) X(x int) *SvgText
- func (t *SvgText) Y(y int) *SvgText
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Case ¶
func Case[T comparable](match T, element Element) any
func EscapeString ¶
Escapes a string to ensure it is safe HTML. Doesnt remove apostrophe
Types ¶
type DefaultElement ¶
type DefaultElement struct {
// contains filtered or unexported fields
}
func NewDefaultElement ¶
func NewDefaultElement(tag string) DefaultElement
Returns a new DefaultElement with the given tag.
func (*DefaultElement) Action ¶
func (e *DefaultElement) Action(action string) Element
Sets the action attribute of the element to the given string.
func (*DefaultElement) Add ¶
func (e *DefaultElement) Add(elements ...Element) Element
Appends the elements as children.
func (*DefaultElement) AddChild ¶
func (e *DefaultElement) AddChild(child Element) Element
Appends the element as a child.
func (*DefaultElement) Alt ¶
func (e *DefaultElement) Alt(alt string) Element
Sets the alt attribute of the element.
func (*DefaultElement) AtClick ¶
func (e *DefaultElement) AtClick(handler string) Element
Sets @click attribute for alpine.js
func (*DefaultElement) Attr ¶
func (e *DefaultElement) Attr(key string, value ...string) Element
Sets the given attribute key to the given value.
func (*DefaultElement) ChildWithId ¶
func (e *DefaultElement) ChildWithId(id string) (Element, bool)
Returns the first child element with the given id recursively.
func (*DefaultElement) Children ¶
func (e *DefaultElement) Children(elements ...Element) Element
Sets the children of the element.
func (*DefaultElement) Class ¶
func (e *DefaultElement) Class(classes ...string) Element
Adds the given class or classes to the element.
func (*DefaultElement) Defer ¶
func (e *DefaultElement) Defer(value ...bool) Element
Sets the defer attribute of the element.
func (*DefaultElement) For ¶
func (e *DefaultElement) For(value string) Element
Sets the for attribute of the element.
func (*DefaultElement) GetAttr ¶
func (e *DefaultElement) GetAttr(key string) string
Returns the value of the given attribute key.
func (*DefaultElement) GetAttrs ¶
func (e *DefaultElement) GetAttrs() map[string]string
Returns a map of the attributes on the element.
func (*DefaultElement) GetChild ¶
func (e *DefaultElement) GetChild(idx int) (Element, bool)
Returns the child element at the given index.
func (*DefaultElement) GetChildren ¶
func (e *DefaultElement) GetChildren() []Element
Returns the children of the element.
func (*DefaultElement) GetChildrenWithClass ¶
func (e *DefaultElement) GetChildrenWithClass(class string) []Element
Returns all descendants with the given class.
func (*DefaultElement) GetClasses ¶
func (e *DefaultElement) GetClasses() []string
Returns an array of all the classes of the element.
func (*DefaultElement) GetContent ¶
func (e *DefaultElement) GetContent() string
Returns the rendered children and text.
func (*DefaultElement) GetFirstChildWithClass ¶
func (e *DefaultElement) GetFirstChildWithClass(class string) (Element, bool)
Returns the first descendant with the given class.
func (*DefaultElement) GetId ¶
func (e *DefaultElement) GetId() string
Returns the id of the element.
func (*DefaultElement) GetNthChildWithClass ¶
func (e *DefaultElement) GetNthChildWithClass(class string, n int) (Element, bool)
Returns the nth descendant with the given class.
func (*DefaultElement) GetStyle ¶
func (e *DefaultElement) GetStyle(key string) string
Returns the value of the given style key.
func (*DefaultElement) GetStyles ¶
func (e *DefaultElement) GetStyles() map[string]string
Returns a map of the styles on the element.
func (*DefaultElement) GetTag ¶
func (e *DefaultElement) GetTag() string
Returns the HTML tag name of the element.
func (*DefaultElement) HXBoost ¶
func (e *DefaultElement) HXBoost(boost ...bool) Element
Sets the hx-boost attribute of the element.
func (*DefaultElement) HXConfirm ¶
func (e *DefaultElement) HXConfirm(prompt string) Element
Sets the hx-confirm attribute of the element.
func (*DefaultElement) HXDelete ¶
func (e *DefaultElement) HXDelete(url string) Element
Sets the hx-delete attribute of the element.
func (*DefaultElement) HXGet ¶
func (e *DefaultElement) HXGet(url string) Element
Sets the hx-get attribute of the element.
func (*DefaultElement) HXHistory ¶
func (e *DefaultElement) HXHistory(history string) Element
Sets the hx-replace-url attribute of the element.
func (*DefaultElement) HXInclude ¶ added in v1.0.5
func (e *DefaultElement) HXInclude(selector string) Element
Sets the hx-include attribute of the element.
func (*DefaultElement) HXIndicator ¶
func (e *DefaultElement) HXIndicator(indicator string) Element
Sets the hx-indicator attribute of the element.
func (*DefaultElement) HXOn ¶
func (e *DefaultElement) HXOn(event string, script string) Element
Sets hx-on attribute for htmx
func (*DefaultElement) HXOob ¶
func (e *DefaultElement) HXOob(oob string) Element
Sets the hx-oob attribute of the element.
func (*DefaultElement) HXPatch ¶
func (e *DefaultElement) HXPatch(url string) Element
Sets the hx-patch attribute of the element.
func (*DefaultElement) HXPost ¶
func (e *DefaultElement) HXPost(url string) Element
Sets the hx-post attribute of the element.
func (*DefaultElement) HXPushUrl ¶
func (e *DefaultElement) HXPushUrl(pushUrl string) Element
Sets the hx-push-url attribute of the element.
func (*DefaultElement) HXPut ¶
func (e *DefaultElement) HXPut(url string) Element
Sets the hx-put attribute of the element.
func (*DefaultElement) HXReplaceUrl ¶
func (e *DefaultElement) HXReplaceUrl(replaceUrl string) Element
Sets the hx-replace-url attribute of the element.
func (*DefaultElement) HXSelect ¶
func (e *DefaultElement) HXSelect(value string) Element
Sets the hx-select attribute of the element.
func (*DefaultElement) HXSwap ¶
func (e *DefaultElement) HXSwap(value string) Element
Sets the hx-swap attribute of the element.
func (*DefaultElement) HXSwapOob ¶
func (e *DefaultElement) HXSwapOob(oob string) Element
Sets the hx-swap-oob attribute of the element.
func (*DefaultElement) HXTarget ¶
func (e *DefaultElement) HXTarget(target string) Element
Sets the hx-target attribute of the element.
func (*DefaultElement) HXTrigger ¶
func (e *DefaultElement) HXTrigger(trigger string) Element
Sets the hx-trigger attribute of the element.
func (*DefaultElement) HXVals ¶
func (e *DefaultElement) HXVals(json string) Element
Sets the hx-vals attribute of the element.
func (*DefaultElement) HasClass ¶
func (e *DefaultElement) HasClass(class string) bool
Returns true if the element has the given class.
func (*DefaultElement) Href ¶
func (e *DefaultElement) Href(href string) Element
Sets the href attribute of the element.
func (*DefaultElement) Id ¶
func (e *DefaultElement) Id(value string) Element
Sets the id attribute of the element.
func (*DefaultElement) Method ¶
func (e *DefaultElement) Method(method string) Element
Sets the method attribute of the element to the given string.
func (*DefaultElement) Name ¶
func (e *DefaultElement) Name(name string) Element
Sets the name attribute of the element.
func (*DefaultElement) OnClick ¶
func (e *DefaultElement) OnClick(value string) Element
Sets the onclick attribute of the element.
func (*DefaultElement) OobOnly ¶
func (e *DefaultElement) OobOnly(w http.ResponseWriter)
Sends the element to the http.ResponseWriter as text/html.
func (*DefaultElement) Placeholder ¶
func (e *DefaultElement) Placeholder(placeholder string) Element
Sets the placeholder attribute of the element.
func (*DefaultElement) Prepend ¶
func (e *DefaultElement) Prepend(elements ...Element) Element
Prepends the elements as children.
func (*DefaultElement) PrependChild ¶
func (e *DefaultElement) PrependChild(child Element) Element
Prepends the element as a child.
func (*DefaultElement) RemoveAttr ¶
func (e *DefaultElement) RemoveAttr(keys ...string) Element
Removes the given attribute key from the element.
func (*DefaultElement) RemoveClass ¶
func (e *DefaultElement) RemoveClass(classes ...string) Element
Removes the given class or classes from the element.
func (*DefaultElement) RemoveStyle ¶
func (e *DefaultElement) RemoveStyle(styles ...string) Element
Removes the given style key from the element.
func (*DefaultElement) Render ¶
func (e *DefaultElement) Render() string
Renders the element as HTML string.
func (*DefaultElement) RenderWithContent ¶
func (e *DefaultElement) RenderWithContent(text string, children ...Element) string
Renders the element with the children first and text at the end.
func (*DefaultElement) Send ¶
func (e *DefaultElement) Send(w http.ResponseWriter)
Sends the element to the http.ResponseWriter as text/html.
func (*DefaultElement) Src ¶
func (e *DefaultElement) Src(src string) Element
Sets the src attribute of the element.
func (*DefaultElement) Style ¶
func (e *DefaultElement) Style(style string) Element
Sets the given style key to the given value.
func (*DefaultElement) Submit ¶
func (e *DefaultElement) Submit() Element
Sets the type attribute to "submit".
func (*DefaultElement) Tag ¶
func (e *DefaultElement) Tag(tag string) Element
Sets the HTML tag name of the element.
func (*DefaultElement) Text ¶
func (e *DefaultElement) Text(content string) Element
Sets the text content of the element.
func (*DefaultElement) Title ¶
func (e *DefaultElement) Title(title string) Element
Sets the title attribute of the element.
func (*DefaultElement) Type ¶
func (e *DefaultElement) Type(tipe string) Element
Sets the type attribute of the element.
func (*DefaultElement) UnsafeHtml ¶
func (e *DefaultElement) UnsafeHtml(content string) Element
Sets the text content of the element without escaping.
func (*DefaultElement) Value ¶
func (e *DefaultElement) Value(value string) Element
Sets the value attribute of the element.
func (*DefaultElement) XBind ¶
func (e *DefaultElement) XBind(attr string, value string) Element
Sets x-bind attribute for alpine.js
func (*DefaultElement) XCloak ¶
func (e *DefaultElement) XCloak() Element
Sets x-cloak attribute for alpine.js
func (*DefaultElement) XData ¶
func (e *DefaultElement) XData(data string) Element
Sets x-data attribute for alpine.js
func (*DefaultElement) XHtml ¶
func (e *DefaultElement) XHtml(value string) Element
Sets x-html attribute for alpine.js
func (*DefaultElement) XInit ¶
func (e *DefaultElement) XInit(value string) Element
Sets x-init attribute for alpine.js
func (*DefaultElement) XModel ¶
func (e *DefaultElement) XModel(value string) Element
Sets x-model attribute for alpine.js
func (*DefaultElement) XOn ¶
func (e *DefaultElement) XOn(event string, value string) Element
Sets x-on attribute for alpine.js
func (*DefaultElement) XRef ¶
func (e *DefaultElement) XRef(value string) Element
Sets x-ref attribute for alpine.js
func (*DefaultElement) XShow ¶
func (e *DefaultElement) XShow(condition string) Element
Sets x-show attribute for alpine.js
func (*DefaultElement) XText ¶
func (e *DefaultElement) XText(value string) Element
Sets x-text attribute for alpine.js
type Element ¶
type Element interface {
// Returns the HTML tag name of the element.
GetTag() string
// Sets the HTML tag name of the element.
Tag(tag string) Element
// Sets the defer attribute of the element.
Defer(value ...bool) Element
// Returns the id of the element.
GetId() string
// Returns the first child element with the given id recursively.
ChildWithId(id string) (Element, bool)
// Returns an array of all the classes of the element.
GetClasses() []string
// Returns true if the element has the given class.
HasClass(class string) bool
// Adds the given class or classes to the element.
Class(classes ...string) Element
// Removes the given class or classes from the element.
RemoveClass(class ...string) Element
// Returns a map of the styles on the element.
GetStyles() map[string]string
// Returns the value of the given style key.
GetStyle(key string) string
// Sets the given style key to the given value.
Style(style string) Element
// Removes the given style key from the element.
RemoveStyle(key ...string) Element
// Returns a map of the attributes on the element.
GetAttrs() map[string]string
// Returns the value of the given attribute key.
GetAttr(key string) string
// Sets the given attribute key to the given value.
Attr(key string, value ...string) Element
// Removes the given attribute key from the element.
RemoveAttr(key ...string) Element
// Returns the children of the element.
GetChildren() []Element
// Returns the child element at the given index.
GetChild(idx int) (Element, bool)
// Appends the element as a child.
AddChild(child Element) Element
// Appends the elements as children.
Add(children ...Element) Element
// Prepends elements as children.
Prepend(children ...Element) Element
// Prepends the element as a child.
PrependChild(child Element) Element
// Sets the children of the element.
Children(children ...Element) Element
// Returns all descendants with the given class.
GetChildrenWithClass(class string) []Element
// Returns the first descendant with the given class.
GetFirstChildWithClass(class string) (Element, bool)
// Returns the nth descendant with the given class.
GetNthChildWithClass(class string, n int) (Element, bool)
// Returns the rendered children and text.
GetContent() string
// Renders the element as HTML string.
Render() string
//// Common attrs
// Sets the text content of the element.
Text(content string) Element
// Sets the HTML content of the element without escaping.
UnsafeHtml(content string) Element
// Sets the hx-post attribute of the element.
HXPost(url string) Element
// Sets the hx-get attribute of the element.
HXGet(url string) Element
// Sets the hx-put attribute of the element.
HXPut(url string) Element
// Sets the hx-patch attribute of the element.
HXPatch(url string) Element
// Sets the hx-delete attribute of the element.
HXDelete(url string) Element
// Sets the hx-confirm attribute of the element.
HXConfirm(prompt string) Element
// Sets the hx-target attribute of the element.
HXTarget(target string) Element
// Sets the hx-trigger attribute of the element.
HXTrigger(trigger string) Element
// Sets the hx-include attribute of the element.
HXInclude(selector string) Element
// Sets the hx-swap attribute of the element.
HXSwap(value string) Element
// Sets the hx-select attribute of the element.
HXSelect(value string) Element
// Sets the id attribute of the element.
Id(value string) Element
// Sets the name attribute of the element.
Name(name string) Element
// Sets the title attribute of the element.
Title(title string) Element
// Sets the for attribute of the element.
For(name string) Element
// Sets the type attribute of the element.
Type(tipe string) Element
// Sets the type attribute to "submit".
Submit() Element
// Sets the method attribute of the element to the given string.
Method(method string) Element
// Sets the action attribute of the element.
Action(action string) Element
// Sets the src attribute of the element.
Src(src string) Element
// Sets the value attribute of the element.
Value(value string) Element
// Sets the href attribute of the element.
Href(href string) Element
// Sets the placeholder attribute of the element.
Placeholder(placeholder string) Element
// Sets the alt attribute of the element.
Alt(alt string) Element
// Sets the onclick attribute of the element.
OnClick(value string) Element
// Sets the hx-indicator attribute of the element.
HXIndicator(indicator string) Element
// Sets the hx-oob attribute of the element.
HXOob(oob string) Element
// Sets the hx-swap-oob attribute of the element.
HXSwapOob(oob string) Element
// Sets the hx-vals attribute of the element.
HXVals(json string) Element
// Sets the hx-push-url attribute of the element.
HXPushUrl(pushUrl string) Element
// Sets the hx-replace-url attribute of the element.
HXReplaceUrl(replaceUrl string) Element
// Sets the hx-history attribute of the element.
HXHistory(history string) Element
// Sets hx-on attribute for htmx
HXOn(event string, value string) Element
// Sets the hx-boost attribute of the element.
HXBoost(boost ...bool) Element
// Sets x-data attribute for alpine.js
XData(data string) Element
// Sets @click attribute for alpine.js
AtClick(handler string) Element
// Sets x-bind attribute for alpine.js
XBind(attr string, value string) Element
// Sets x-on attribute for alpine.js
XOn(event string, value string) Element
// Sets x-text attribute for alpine.js
XText(value string) Element
// Sets x-html attribute for alpine.js
XHtml(value string) Element
// Sets x-model attribute for alpine.js
XModel(value string) Element
// Sets x-show attribute for alpine.js
XShow(condition string) Element
// Sets x-init attribute for alpine.js
XInit(value string) Element
// Sets x-ref attribute for alpine.js
XRef(value string) Element
// Sets x-cloak attribute for alpine.js
XCloak() Element
Send(w http.ResponseWriter)
OobOnly(w http.ResponseWriter)
}
func A ¶
Returns a new a element with the given href. If children are provided, they will be used as the content of the link.
func Div ¶
Returns a new div element with the given class. If children are provided, they will be added as the content of the div.
func Fragment ¶
Returns a new element with no tag If children are provided, they will be added as the content of the element.
func HiddenInput ¶
Returns a new hidden input element with the given name and value.
func Li ¶
returns a list item (li) tag If children are provided, they will be added as the content of the list item.
func List ¶
Returns a list of elements from the given data wrapped in a div using an optional function to render each item.
func Picture ¶
func Picture(alt string, sources ...PictureSource) Element
func Script ¶
returns a script tag If js is provided, it will be used as the UNESCAPED content of the script tag.
func Section ¶
Returns a new section element If children are provided, they will be added as the content of the section.
func String ¶
returns a simple string content as an element This is useful for creating text nodes without any HTML tags.
func Stylesheet ¶
returns a stylesheet link The url parameter specifies the URL of the stylesheet. The link tag is set to have a rel attribute of "stylesheet". It is used to link external CSS files to the HTML document.
func Switch ¶
func Switch[T comparable](value T, items ...any) Element
func Table ¶
returns a table element If children are provided, they will be added as the content of the table.
func Td ¶
returns a table cell element If children are provided, they will be added as the content of the cell.
func Template ¶
returns an Alpine template element If children are provided, they will be added as the content of the template.
func Th ¶
returns a table header row element If children are provided, they will be added as the content of the header row.
func Title ¶
Returns a new title element with the given text. This is typically used for the title of an HTML document.
func Tr ¶
returns a table row element If children are provided, they will be added as the content of the row.
func Ul ¶
returns a unordered list (ul) tag If children are provided, they will be added as the content of the unordered list.
func VideoIframe ¶
returns an iframe tag The title parameter sets the title attribute of the iframe. The width and height parameters specify the dimensions of the iframe. The src parameter specifies the source URL of the iframe. The iframe is set to allow autoplay, fullscreen, picture-in-picture, and clipboard-write. It also has a class of "w-full h-full" for styling. The data-ready attribute is set to "true" to indicate that the iframe is ready. The frameborder attribute is set to "0" to remove the border around the iframe.
type Field ¶
type Field struct {
DefaultElement
Label Element
Input Element
Error Element
Check Element
}
func HiddenField ¶
func (*Field) Email ¶
Sets the type of the input element to "email" if is_email is not specified or true Sets type to "text" if is_email is false
type Option ¶
func OptionStrings ¶
type PictureSource ¶
type SvgCircle ¶
type SvgCircle struct {
DefaultElement
}
func (*SvgCircle) FillOpacity ¶
func (*SvgCircle) StrokeDasharray ¶
func (*SvgCircle) StrokeLinecap ¶
func (*SvgCircle) StrokeLinejoin ¶
func (*SvgCircle) StrokeMiterlimit ¶
func (*SvgCircle) StrokeOpacity ¶
func (*SvgCircle) StrokeWidth ¶
type SvgElement ¶
type SvgElement struct {
DefaultElement
}
func Svg ¶
func Svg(children ...Element) *SvgElement
func (*SvgElement) D ¶
func (s *SvgElement) D(d string) *SvgElement
func (*SvgElement) Height ¶
func (s *SvgElement) Height(height int) *SvgElement
func (*SvgElement) Version ¶
func (s *SvgElement) Version(version string) *SvgElement
func (*SvgElement) ViewBox ¶
func (s *SvgElement) ViewBox(x, y, width, height int) *SvgElement
func (*SvgElement) Width ¶
func (s *SvgElement) Width(width int) *SvgElement
func (*SvgElement) Xmlns ¶
func (s *SvgElement) Xmlns(xmlns string) *SvgElement
func (*SvgElement) XmlnsXlink ¶
func (s *SvgElement) XmlnsXlink(xmlnsXlink string) *SvgElement
type SvgGroup ¶
type SvgGroup struct {
DefaultElement
}
type SvgImage ¶
type SvgImage struct {
DefaultElement
}
type SvgLine ¶
type SvgLine struct {
DefaultElement
}
func (*SvgLine) FillOpacity ¶
func (*SvgLine) StrokeDasharray ¶
func (*SvgLine) StrokeDashoffset ¶
func (*SvgLine) StrokeLinecap ¶
func (*SvgLine) StrokeLinejoin ¶
func (*SvgLine) StrokeMiterlimit ¶
func (*SvgLine) StrokeWidth ¶
type SvgPath ¶
type SvgPath struct {
DefaultElement
}
func (*SvgPath) PathLength ¶
func (*SvgPath) StrokeDasharray ¶
func (*SvgPath) StrokeDashoffset ¶
func (*SvgPath) StrokeLinecap ¶
func (*SvgPath) StrokeLinejoin ¶
func (*SvgPath) StrokeMiterlimit ¶
func (*SvgPath) StrokeWidth ¶
type SvgRect ¶
type SvgRect struct {
DefaultElement
}
func (*SvgRect) FillOpacity ¶
func (*SvgRect) StrokeDasharray ¶
func (*SvgRect) StrokeLinecap ¶
func (*SvgRect) StrokeLinejoin ¶
func (*SvgRect) StrokeMiterlimit ¶
func (*SvgRect) StrokeOpacity ¶
func (*SvgRect) StrokeWidth ¶
type SvgText ¶
type SvgText struct {
DefaultElement
}