hb

package module
v1.88.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: MIT Imports: 8 Imported by: 32

README

HTML Builder Open in Gitpod

tests Go Report Card PkgGoDev

Unpretentious short and sweet declarative HTML Builder.

Demos can be found on: https://golangui.com

Benefits

  • Valid (X)HTML
  • Programmatically generate (X)HTML
  • Pure GO code
  • Full support, and autocomplete by your favorite editor
  • No need to transfer HTML files
  • No need to embed HTML files
  • No need for using template files
  • Full reuse of the code
  • Fully eliminates the quirks of the standard template package
  • Great for email templates too
  • Nice looking fluent interface
  • Easy to extend and build your own flavor on top
  • Dynamic UI with conditions
  • Conditional attributes
  • Lots of demos and examples
  • Works with any CSS library
  • Works with any JS library
  • Out of the box support for Alpine.js
  • Out of the box support for HTMX

Example

  • Section containing div container (Bootstrap) with a message "Hello world"
// imported to global namespace, to avoid typing hb.* each time
import . "github.com/dracory/hb"

// or, regular import, and type hb.* before using it each time
// import "github.com/dracory/hb"

// 1. Create a container div with a "Hello world" message inside
container := Div().Class("container").Text("Hello world")

// 2. Create a section with padding of 40px containing the container
section := Section().Style("padding:40px;").Child(container)

// 3. Render to HTML to display
html := section.ToHTML()

!!! For more examples look below in the README

Installation

go get -u github.com/dracory/hb

Implemented Tag Shortcuts

  • A() - shortcut for <a> tag
  • Abbr() - shortcut for <abbr> tag
  • Address() - shortcut for <address> tag
  • Article() - shortcut for <article> tag
  • Aside() - shortcut for <aside> tag
  • BR() / Br() - shortcut for <br> tag
  • Button() - shortcut for <button> tag
  • Caption() - shortcut for <caption> tag
  • Code() - shortcut for <code> tag
  • Div() - shortcut for <div> tag
  • Form() - shortcut for <form> tag
  • I() - shortcut for <i> tag
  • Header() - shortcut for <header> tag
  • Heading1() - shortcut for <h1> tag
  • Heading2() - shortcut for <h2> tag
  • Heading3() - shortcut for <h3> tag
  • Heading4() - shortcut for <h4> tag
  • Heading5() - shortcut for <h5> tag
  • Heading6() - shortcut for <h6> tag
  • Hyperlink() - shortcut for <a> tag
  • HR() / Hr() - shortcut for <hr> tag
  • HTML(html string) - creates empty tag with the HTML content
  • Image() - shortcut for <img> tag
  • Input() - shortcut for <input> tag
  • LI() / Li() - shortcut for <li> tag
  • Label() - shortcut for <label> tag
  • Nav() - shortcut for <nav> tag
  • Navbar() - shortcut for <navbar> tag
  • OL() / Ol() - shortcut for <ol> tag
  • Option() - shortcut for <option> tag
  • Paragraph() - shortcut for <p> tag
  • PRE() - shortcut for <pre> tag
  • Script() - shortcut for <script> tag
  • ScriptURL() - shortcut for <script src="{SRC}"> tag
  • Select() - shortcut for <select> tag
  • Small() - shortcut for <small> tag
  • Span() - shortcut for <span> tag
  • Style() - shortcut for <style> tag
  • StyleURL() - shortcut for <link> tag
  • Section() - shortcut for <section> tag
  • Sub() - shortcut for <sub> tag
  • Sup() - shortcut for <sup> tag
  • NewTag(tagName string) - for custom tags
  • Table() - shortcut for <table> tag
  • Tbody() / TBody() - shortcut for <tbody> tag
  • TD() / Td() - shortcut for <td> tag
  • Template() - shortcut for <template> tag
  • Text(text string) - creates empty tag with the escaped text content
  • TextArea() / Textarea() - shortcut for <textarea> tag
  • TH() / Th() - shortcut for <th> tag
  • Thead() / THead() - shortcut for <thead> tag
  • Tfoot() / TFoot() - shortcut for <tfoot> tag
  • TR() / Tr() - shortcut for <tr> tag
  • UL() / Ul() - shortcut for <ul> tag
  • Webpage() - full HTML page withe head, body, meta, styles and scripts
  • Wrap() - convenience method to taglessly (without a root wrapping element) group elements together

Examples can be found on: https://golangui.com

Tag Methods

  • Action(action string) - shortcut to add an "action" attribute
  • Aria(key, value string) - shortcut for "aria-" attribute
  • Attr(key, value string) - shortcut for SetAttribute
  • AttrIf(condition bool, key, value string) - conditional setting of attribute
  • AttrIfF(condition bool, key string, valueFunc func() string) - conditional setting of attribute using function
  • AttrIfElse(condition bool, key, valueIf string, valueElse string) - conditional setting of attribute
  • Attrs(map[string]string) - shortcut for setting multiple attributes
  • AttrsIf(condition bool, attrs map[string]string) - conditional setting of attributes
  • AttrsIfF(condition bool, attrsFunc func() map[string]string) - conditional setting of attributes using function
  • AttrsIfElse(condition, attrsIf map[string]string, attrsElse map[string]string) - conditional setting of attributes
  • AddChild(tag Tag) - adds a child element
  • AddChildren(tag []Tag) - adds an array of child elements
  • AddClass(className string) - adds a class name to the "class" attribute
  • AddHTML(html string) - adds HTML content to the element
  • AddStyle(style string) - adds a style to the "style" attribute
  • AddText(text string) - adds escaped text content to the element
  • Child(tag Tag) - shortcut for AddChild
  • ChildIf(condition bool, tag Tag) - conditional adding of a child
  • ChildIfF(condition bool, childFunc func() *Tag) - conditional adding of a child using function
  • ChildIfElse(condition bool, childIf Tag, childElse Tag) - conditional adding of a child
  • Children(children []Tag) - shortcut for AddChildren
  • ChildrenIf(condition bool, children []Tag) - conditional adding of children
  • ChildrenIfF(condition bool, childrenFunc func() []*Tag) - conditional adding of children using function
  • ChildrenIfElse(condition bool, childrenIf []Tag, childrenElse []Tag) - conditional adding of a children
  • Class(className string) - shortcut for AddClass
  • ClassIf(condition bool, className string) - conditional adding of a class
  • ClassIfElse(condition bool, classNameIf string, classNameElse string) - conditional adding of a class
  • Data(name string, value string) - shortcut to add a "data-" attribute
  • DataIf(condition bool, key, value string) - conditional setting of attribute
  • DataIfElse(condition bool, key, valueIf string, valueElse string) - conditional setting of attribute
  • Enctype(enctype string) - shortcut to add an "enctype" attribute
  • HasClass(className string) - checks if the class is available
  • Href(href string) - shortcut to add an "href" attribute
  • HTML(html string) - shortcut for AddHTML
  • ID(className string) - shortcut to add an "id" attribute
  • GetAttribute(key string) string
  • Method(method string) - shortcut to add a "method" attribute
  • Name(name string) - shortcut to add a "name" attribute
  • Placeholder(placeholder string) - shortcut to add a "placeholder" attribute
  • OnBlur(js string) - shortcut to add an "onblur" attribute
  • OnChange(js string) - shortcut to add an "onchange" attribute
  • OnClick(js string) - shortcut to add an "onclick" attribute
  • OnDblClick(js string) - shortcut to add an "ondblclick" attribute
  • OnFocus(js string) - shortcut to add an "onfocus" attribute
  • OnKeyDown(js string) - shortcut to add an "onkeydown" attribute
  • OnKeyPress(js string) - shortcut to add an "onkeypress" attribute
  • OnKeyUp(js string) - shortcut to add an "onkeyup" attribute
  • OnMouseDown(js string) - shortcut to add an "onmousedown" attribute
  • OnMouseOut(js string) - shortcut to add an "onmouseout" attribute
  • OnMouseUp(js string) - shortcut to add an "onmouseup" attribute
  • OnSubmit(js string) - shortcut to add an "onsubmit" attribute
  • ReadOnly(isReadOnly bool) - shortcut to add a "readonly" attribute
  • Rel(rel string) - shortcut to add a "rel" attribute
  • Role(role string) - shortcut to add a "role" attribute
  • Required(isRequired bool) - shortcut to add a "required" attribute
  • Selected(isSelected bool) - shortcut to add a "selected" attribute
  • SetAttribute(key, value string) - sets an attribute (i.e. id, class, etc)
  • Src(src string) - shortcut to add a "src" attribute
  • Style(style string) - shortcut to add a "style" attribute
  • StyleIf(condition bool, style string) - conditional adding of a style
  • StyleIfElse(condition bool, styleIf string, styleElse string) - conditional adding of a style
  • Target(target string) - shortcut to add a "target" attribute
  • TargetIf(condition bool, target string) - conditional adding of a "target" attribute
  • Text(html string) - shortcut for AddText
  • TextIf(condition bool, text string) - adds escaped text if a condition is met
  • TextIfElse(condition bool, textIf string, textElse string) - adds escaped text if a condition is met
  • Title(title string) - shortcut for setting the "title" attribute
  • TitleIf(condition bool, title string) - sets the title if a condition is met
  • ToHTML() string - outputs HTML code
  • Type(target string) - shortcut to add a "type" attribute
  • TypeIf(condition bool, target string) - conditional setting of "type" attribute
  • Value(value string) - shortcut to add a "value" attribute
  • ValueIf(condition bool, value string) - conditional setting of "value" attribute

Examples can be found on: https://golangui.com

Utility

  • ToTags[T any](items []T, callback func(item T, index int) *Tag) []*Tag - transforms a slice of anything to a slice of tags
  • If(condition bool, trueTag *Tag) *Tag
  • IfF(condition bool, trueFunc func() *Tag) *Tag
  • IfElse(condition bool, trueTag *Tag, falseTag *Tag) *Tag
  • IfFElseF(condition bool, trueFunc func() *Tag, falseFunc func() *Tag) *Tag
  • Ternary(condition bool, trueTag *Tag, falseTag *Tag) *Tag
  • TernaryF(condition bool, trueFunc func() *Tag, falseFunc func() *Tag) *Tag

Tag HTMX Attributes

HTMX (https://htmx.org/reference/) is a great match for Golang, therefore here is a shortcut for working with HTMX.

  • Hx(name string, value string) - shortcut for setting an HTMX attribute
  • HxConfirm(value string)
  • HxDelete(value string)
  • HxGet(value string)
  • HxInclude(value string)
  • HxIndicator(value string)
  • HxOn(name string, value string)
  • HxPatch(value string)
  • HxPost(value string)
  • HxPut(value string)
  • HxSelect(value string)
  • HxSelectOob(value string)
  • HxSync(value string)
  • HxSwap(value string)
  • HxSwapOob(value string)
  • HxTarget(value string)
  • HxTrigger(value string)
  • HxVals(value string)
  • HxVars(value string)

Examples can be found on: https://golangui.com

Tag Alpine.js Attributes

Alpine.js (https://alpinejs.dev/) is a great match for Golang, therefore here is a shortcut for working with HTMX.

  • X(name string, value string) - shortcut for setting an AlpineJS attribute
  • XBind(name string, value string)
  • XOn(name string, value string)

Examples can be found on: https://golangui.com

Webpage Methods

  • AddChild(child *Tag)
  • SetFavicon(favicon string)
  • SetTitle(title string)
  • AddScripts(scripts []string)
  • AddScript(script string)
  • AddScriptURLs(scriptURLs []string)
  • AddScriptURL(scriptURL string)
  • AddStyle(style string)
  • AddStyles(styles []string)
  • AddStyleURL(styleURL string)
  • AddStyleURLs(styleURLs []string)

Border Layout Methods

  • NewBorderLayout() - shortcut to quickly create a border layout with top, bottom, left, right and center slots (see example below how to use it)
  • AddTop(tag *Tag, alignHorizontal string, alignVertical string)
  • AddBottom(tag *Tag, alignHorizontal string, alignVertical string)
  • AddLeft(tag *Tag, alignHorizontal string, alignVertical string)
  • AddRight(tag *Tag, alignHorizontal string, alignVertical string)
  • AddCenter(tag *Tag, alignHorizontal string, alignVertical string)

Usage example:

bl := NewBorderLayout()
	bl.AddTop(NewSpan().Text("TOP"), BORDER_LAYOUT_ALIGN_CENTER, BORDER_LAYOUT_ALIGN_MIDDLE)
	bl.AddCenter(NewSpan().Text("CENTER"), BORDER_LAYOUT_ALIGN_CENTER, BORDER_LAYOUT_ALIGN_MIDDLE)
	bl.AddBottom(NewSpan().Text("BOTTOM"), BORDER_LAYOUT_ALIGN_CENTER, BORDER_LAYOUT_ALIGN_MIDDLE)
	bl.AddLeft(NewSpan().Text("LEFT"), BORDER_LAYOUT_ALIGN_CENTER, BORDER_LAYOUT_ALIGN_MIDDLE)
	bl.AddRight(NewSpan().Text("RIGHT"), BORDER_LAYOUT_ALIGN_CENTER, BORDER_LAYOUT_ALIGN_MIDDLE)
blHtml := bl.ToHTML()

Swal

Usage example in a form:

form.
	ChildIf(data.formErrorMessage != "", hb.Swal(swal.SwalOptions{
		Icon:              "error",
		Title:             "Oops...",
		Text:              data.formErrorMessage,
		ShowCancelButton:  false,
		ConfirmButtonText: "OK",
		ConfirmCallback:   "window.location.href = window.location.href",
	})).
	ChildIf(data.formSuccessMessage != "", hb.Swal(swal.SwalOptions{
		Icon:              "success",
		Title:             "Saved",
		Text:              data.formSuccessMessage,
		ShowCancelButton:  false,
		ConfirmButtonText: "OK",
		ConfirmCallback:   "window.location.href = window.location.href",
	}))

Working with Raw Tags

tag := &Tag{
	TagName: "custom-element",
}
tag.toHTML()

Safe Escaping HTML

For safeguarding HTML, always use the .Text(text) method of the tags, it will automatically escape any HTML tags in the output.

Using the .HTML(html) method of the tags, will output the raw HTML, and leaves you vulnerable to XSS attacks.

You can escape the HTML yourself by using the EscapeString method from the standard HTML library Link with example: https://golang.org/pkg/html/#EscapeString

Examples

  • Bootstrap login form
// Elements for the form
header := Heading3().text("Please sign in").Style("margin:0px;")
emailLabel := Label().Text("E-mail Address")
emailInput := Input().Class("form-control").Name("email").Placeholder("Enter e-mail address")
emailFormGroup := Div().Class("form-group").Child(emailLabel).Child(emailInput)
passwordLabel := Label().Child(hb.Text("Password"))
passwordInput := Input().Class("form-control").Name("password").Type("password").Placeholder("Enter password")
passwordFormGroup := Div().Class("form-group").Child(passwordLabel).Child(passwordInput)
buttonLogin := Button().Class("btn btn-lg btn-success btn-block").Text("Login")
buttonRegister := Hyperlink().Class("btn btn-lg btn-info float-left").Text("Register").Href("auth/register")
buttonForgotPassword := Hyperlink().Class("btn btn-lg btn-warning float-right").Text("Forgot password?").Href("auth/password-restore")

// Add elements in a card
cardHeader := Div().
	Class("card-header").
	Child(header)

cardBody := Div().
	Class("card-body").
	Children([]*hb.Tag{
		emailFormGroup,
		passwordFormGroup,
		buttonLogin,
	})

cardFooter := Div().
	Class("card-footer").
	Children([]*hb.Tag{
		buttonRegister,
		buttonForgotPassword,
	})

card := Div().
	Class("card card-default").
	Style("margin:0 auto;max-width: 360px;").
	Children([]*hb.Tag{
		cardHeader,
		cardBody,
		cardFooter
	})

// Convert to HTML to display
html := card.ToHTML()

Result:

  • Webpage with title, favicon, Font Awesome icons 4.7.0, jQuery 3.2.1, and Bootstrap 4.5
// 1. Webpage Title
title := "Title"

// 2. Webpage Favicon
favicon := "data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAABNTU0AVKH/AOPj4wDExMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACIiAREQEREAIiIBERAREQAiIgIiICIiACIiAiIgIiIAMzMDMzAzMwAzMwMzMDMzACIiAiIgIiIAIiICIiAiIgAzMwMzMDMzADMzAzMwMzMAIiICIiAiIgAiIgIiICIiAAAAAAAAAAAAIiICIiAiIgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

// 3. Webpage
webpage := NewWebpage().
	SetTitle(title).
	SetFavicon(favicon).
	AddStyleURLs([]string{
		"https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css",
		"https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css",
	}).
	AddScriptURLs([]string{
		"https://code.jquery.com/jquery-3.2.1.min.js",
		"https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.bundle.min.js",
	}).
	AddStyle(`html,body{height:100%;font-family: Ubuntu, sans-serif;}`).AddChild(NewDiv().Text("Hello"))
  • Wrap webpage in a function to be reused as a master template
// Webpage returns the webpage template for the website
func Webpage(title, content string) *hb.Webpage {
	faviconImgCms := `data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAmzKzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEQEAAQERAAEAAQABAAEAAQABAQEBEQABAAEREQEAAAERARARAREAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAAi6MAALu7AAC6owAAuC8AAIkjAAD//wAA//8AAP//AAD//wAA`
	webpage := hb.Webpage()
	webpage.SetTitle(title)
	webpage.SetFavicon(faviconImgCms)

	webpage.AddStyleURLs([]string{
		"https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css",
	})
	webpage.AddScriptURLs([]string{
		"https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js",
		"http://code.jquery.com/jquery-3.5.1.min.js",
		"https://unpkg.com/vue@next",
		"https://cdn.jsdelivr.net/npm/sweetalert2@9",
	})
	webpage.AddScripts([]string{})
	webpage.AddStyle(`html,body{height:100%;font-family: Ubuntu, sans-serif;}`)
	webpage.AddStyle(`body {
		font-family: "Nunito", sans-serif;
		font-size: 0.9rem;
		font-weight: 400;
		line-height: 1.6;
		color: #212529;
		text-align: left;
		background-color: #f8fafc;
	}`)
	webpage.AddChild(hb.HTML(content))
	return webpage
}

// Generate HTML
html := webpage("Home", "Hello world").ToHTML()

HTMX Example

Here is an HTMX example which submits the content of all the inputs in a div to the server (no need to be in a form) and then replaces the content of the webpage with the result.

input := NewButton().
		Text("Submit")
		Hx("post", "http://test.com").
		Hx("include", "#DivID").
		Hx("target", "#PageID").
		Hx("swap", "outerHTML")

How to Add a Redirection?

webpage.Meta(hb.Meta().Attr("http-equiv", "refresh").Attr("content", "2; url = https://www.yahoo.com"))

Stargazers over time

Stargazers over time

Similar

Changelog

2025.07.02 - Added Small() shortcut

2025.02.22 - Updated README.md with latest changes.

2025.01.19 - Added additional Sweetalert options to redirect after delay

2024.11.26 - Added Aria, Readonly, Required, Selected

2024.10.05 - Added HxIndicator

2024.10.01 - Added additional shortcuts for more concise declaration

2023.12.17 - Added ToTags, Ternary, Text

2023.12.10 - Added Swal method for quickly adding Sweetalert

2023.09.16 - Added special case for empty "value" attribute

2023.07.26 - Added NewCaption function and Alpine.js, HTMX functions

2023.07.02 - Added NewHeader function

2023.06.09 - Added functional conditions AttrIfF, AttrsIfF, ChildIfF, ChildrenIfF

2023.05.08 - Added Alt attribute shortcut

2023.05.01 - Added NewWrap function

2023.04.27 - Added OnDblClick, OnInput, OnKeyPress, OnMouseDown, OnMouseUp, and conditionals for data

2023.04.25 - Added Placeholder, and conditionals for attributes

2023.04.15 - Added AddStyle, Src, and conditionals for style

2023.04.14 - Added Type attribute shortcut, conditionals for children and class names

2023.03.26 - Added Hx attribute shortcut for working with HTMX

2023.03.26 - Added OnBlur, OnChange, OnFocus, OnKeyDown, OnKeyUp, attribute shortcuts

2023.03.26 - Added Enctype, Href, Method, Name, target, Value attribute shortcuts

2023.01.22 - Added shortcut for <footer> tag

2023.01.14 - Flow pattern applied to BorderLayout methods

2022.09.07 - Added Child and Children shortcuts

2022.08.29 - Added default favicon to Webpage to fix 404 if missing

2022.01.07 - Added Attrs shortcut for setting multiple attributes

2021.07.30 - Added shortcut for <hr> tag

2021.03.20 - Renamed package name to hb to not conflict/confuse with the standard html package

2021.03.18 - Added shortcuts for <template> tag

2021.02.26 - Added shortcuts for <sub>, <sup> tags

2021.01.03 - Added example for webpage layout, and screenshot

2020.12.28 - Added shortcuts for <code>, <pre> tags, shortcuts sorted alphabetically

2020.12.27 - Added shortcuts for <table>, <thead>, <tbody>, <tr>, <th>, <td> tags

2020.12.26 - Fix for attribute escapes, added tests

2020.09.16 - Added shortcuts for <nav>, <navbar>, <ol>, <ul>, <li> tags

2020.06.16 - Initial commit

Aternatives

Star History Chart

Documentation

Overview

Package hb provides HTMX integration for HTML builder HTMX is a modern library that allows AJAX requests directly from HTML See https://htmx.org for complete documentation

Index

Constants

View Source
const BORDER_LAYOUT_ALIGN_BOTTOM = "bottom"
View Source
const BORDER_LAYOUT_ALIGN_CENTER = "center"
View Source
const BORDER_LAYOUT_ALIGN_LEFT = "left"
View Source
const BORDER_LAYOUT_ALIGN_MIDDLE = "middle"
View Source
const BORDER_LAYOUT_ALIGN_RIGHT = "right"
View Source
const BORDER_LAYOUT_ALIGN_TOP = "top"
View Source
const DEFAULT_FAVICON = "" /* 1561-byte string literal not displayed */
View Source
const ENCTYPE_FORM_MULTIPART = "multipart/form-data"

ENCTYPE_MULTIPART_FORM_DATA ("multipart/form-data") Necessary if the user will upload a file through the form

View Source
const ENCTYPE_FORM_TEXT = "text/plain"

ENCTYPE_FORM_TEXT ("text/plain") plain text An ambiguous format, human-readable content not reliably interpretable by computer

View Source
const ENCTYPE_FORM_URLENCODED = "application/x-www-form-urlencoded"

ENCTYPE_FORM_URLENCODED ("application/x-www-form-urlencoded") default encoding of forms. All characters are converted. Spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values)

View Source
const TYPE_BUTTON = "button"
View Source
const TYPE_CHECKBOX = "checkbox"
View Source
const TYPE_COLOR = "color"
View Source
const TYPE_DATE = "date"
View Source
const TYPE_DATETIME = "datetime-local"
View Source
const TYPE_EMAIL = "email"
View Source
const TYPE_FILE = "file"
View Source
const TYPE_HIDDEN = "hidden"
View Source
const TYPE_IMAGE = "image"
View Source
const TYPE_MONTH = "month"
View Source
const TYPE_NUMBER = "number"
View Source
const TYPE_PASSWORD = "password"
View Source
const TYPE_RADIO = "radio"
View Source
const TYPE_RANGE = "range"
View Source
const TYPE_RESET = "reset"
View Source
const TYPE_SEARCH = "search"
View Source
const TYPE_SUBMIT = "submit"
View Source
const TYPE_TEL = "tel"
View Source
const TYPE_TEXT = "text"
View Source
const TYPE_TIME = "time"
View Source
const TYPE_URL = "url"
View Source
const TYPE_WEEK = "week"

Variables

This section is empty.

Functions

func TestTagOption

func TestTagOption(t *testing.T)

func TestTagPRE

func TestTagPRE(t *testing.T)

func TestTagSelect

func TestTagSelect(t *testing.T)

Types

type BorderLayout

type BorderLayout struct {
	Tag
	// contains filtered or unexported fields
}

* * The BorderLayout type is an advanced layout. * * It arranges its children in five regions: top, bottom, left, right, and center. * Each region may contain no more than one widget. * <code> * // Creating a new instance of BorderLayout * borderlayout = NewBorderLayout() * AddChild("HEADER", BORDER_LAYOUT_ALIGN_CENTER, BORDER_LAYOUT_ALIGN_MIDDLE); * AddChild("CONTENT", BORDER_LAYOUT_ALIGN_CENTER, BORDER_LAYOUT_ALIGN_MIDDLE); * AddChild("FOOTER", BORDER_LAYOUT_ALIGN_CENTER, BORDER_LAYOUT_ALIGN_MIDDLE); * AddChild("MENU", BORDER_LAYOUT_ALIGN_CENTER, BORDER_LAYOUT_ALIGN_MIDDLE); * AddChild("ADDS", BORDER_LAYOUT_ALIGN_CENTER, BORDER_LAYOUT_ALIGN_MIDDLE); * </code>

func NewBorderLayout

func NewBorderLayout() *BorderLayout

func (*BorderLayout) AddBottom

func (bl *BorderLayout) AddBottom(tag TagInterface, alignHorizontal, alignVertical string) *BorderLayout

func (*BorderLayout) AddCenter

func (bl *BorderLayout) AddCenter(tag TagInterface, alignHorizontal, alignVertical string) *BorderLayout

func (*BorderLayout) AddLeft

func (bl *BorderLayout) AddLeft(tag TagInterface, alignHorizontal, alignVertical string) *BorderLayout

func (*BorderLayout) AddRight

func (bl *BorderLayout) AddRight(tag TagInterface, alignHorizontal, alignVertical string) *BorderLayout

func (*BorderLayout) AddTop

func (bl *BorderLayout) AddTop(tag TagInterface, alignHorizontal, alignVertical string) *BorderLayout

func (*BorderLayout) SetHeightPercents

func (bl *BorderLayout) SetHeightPercents(height int) *BorderLayout

func (*BorderLayout) SetHeightPixels

func (bl *BorderLayout) SetHeightPixels(height int) *BorderLayout

func (*BorderLayout) SetWidthPercents

func (bl *BorderLayout) SetWidthPercents(width int) *BorderLayout

func (*BorderLayout) SetWidthPixels

func (bl *BorderLayout) SetWidthPixels(width int) *BorderLayout

func (*BorderLayout) ToHTML

func (bl *BorderLayout) ToHTML() string

BorderLayout returns HTML representation of the layout

type HtmlWebpage

type HtmlWebpage struct {
	Tag
	// contains filtered or unexported fields
}

Webpage represents a new web page

func NewWebpage

func NewWebpage() *HtmlWebpage

NewWebpage returns a webpage instance Shortcut method exists: Webpage()

func Webpage

func Webpage(children ...TagInterface) *HtmlWebpage

Webpage is a shortcut to create a new HTML page

func (*HtmlWebpage) AddChild

func (w *HtmlWebpage) AddChild(child TagInterface) *HtmlWebpage

AddChild adds a tag to the webpage

func (*HtmlWebpage) AddChildren

func (w *HtmlWebpage) AddChildren(children []TagInterface) *HtmlWebpage

AddChildren adds tags to the webpage

func (*HtmlWebpage) AddHTML

func (w *HtmlWebpage) AddHTML(html string) *HtmlWebpage

AddHTML adds an HTML to the body of the webpage

func (*HtmlWebpage) AddMeta

func (w *HtmlWebpage) AddMeta(meta TagInterface) *HtmlWebpage

func (*HtmlWebpage) AddScript

func (w *HtmlWebpage) AddScript(script string) *HtmlWebpage

AddScript adds a script to the webpage

func (*HtmlWebpage) AddScriptURL

func (w *HtmlWebpage) AddScriptURL(scriptURL string) *HtmlWebpage

AddScriptURL adds a style URL to the webpage

func (*HtmlWebpage) AddScriptURLs

func (w *HtmlWebpage) AddScriptURLs(scriptURLs []string) *HtmlWebpage

AddScriptURLs adds style URLs to the webpage

func (*HtmlWebpage) AddScripts

func (w *HtmlWebpage) AddScripts(scripts []string) *HtmlWebpage

AddScripts adds scripts to the webpage

func (*HtmlWebpage) AddStyle

func (w *HtmlWebpage) AddStyle(style string) *HtmlWebpage

AddStyle adds a style to the webpage

func (*HtmlWebpage) AddStyleURL

func (w *HtmlWebpage) AddStyleURL(styleURL string) *HtmlWebpage

AddStyleURL adds a style URL to the webpage

func (*HtmlWebpage) AddStyleURLs

func (w *HtmlWebpage) AddStyleURLs(styleURLs []string) *HtmlWebpage

AddStyleURLs adds style URLs to the webpage

func (*HtmlWebpage) AddStyles

func (w *HtmlWebpage) AddStyles(styles []string) *HtmlWebpage

AddStyles adds styles to the webpage

func (*HtmlWebpage) Attr

func (w *HtmlWebpage) Attr(key, value string) *HtmlWebpage

Attr shortcut for SetAttribute

func (*HtmlWebpage) Attrs

func (w *HtmlWebpage) Attrs(attrs map[string]string) *HtmlWebpage

Attrs shortcut for setting multiple attributes

func (*HtmlWebpage) Body

func (w *HtmlWebpage) Body() *Tag

Body returns a pointer to the body tag

func (*HtmlWebpage) Child

func (w *HtmlWebpage) Child(child TagInterface) *HtmlWebpage

AddChild shortcut for AddChild

func (*HtmlWebpage) Children

func (w *HtmlWebpage) Children(children []TagInterface) *HtmlWebpage

Children shortcut for AddChildren

func (*HtmlWebpage) HTML

func (w *HtmlWebpage) HTML(html string) *HtmlWebpage

HTML shortcut for adding HTML to the body

func (*HtmlWebpage) Head

func (w *HtmlWebpage) Head() *Tag

Head returns a pointer to the head tag

func (*HtmlWebpage) Meta

func (w *HtmlWebpage) Meta(meta *Tag) *HtmlWebpage

Meta shortcut for adding a meta

func (*HtmlWebpage) Script

func (w *HtmlWebpage) Script(script string) *HtmlWebpage

Script shortcut for adding a script

func (*HtmlWebpage) ScriptURL

func (w *HtmlWebpage) ScriptURL(scriptURL string) *HtmlWebpage

ScriptURL shortcut for adding a script URL

func (*HtmlWebpage) ScriptURLs

func (w *HtmlWebpage) ScriptURLs(scriptURLs []string) *HtmlWebpage

ScriptURLs shortcut for adding script URLs

func (*HtmlWebpage) SetAttribute

func (w *HtmlWebpage) SetAttribute(key, value string) *HtmlWebpage

SetAttribute adds a style to the webpage

func (*HtmlWebpage) SetCharset

func (w *HtmlWebpage) SetCharset(charset string) *HtmlWebpage

SetCharset sets the charset of the webpage

func (*HtmlWebpage) SetFavicon

func (w *HtmlWebpage) SetFavicon(favicon string) *HtmlWebpage

SetFavicon sets the favicon of the webpage

func (*HtmlWebpage) SetLanguage

func (w *HtmlWebpage) SetLanguage(language string) *HtmlWebpage

SetLanguage sets the language of the webpage

func (*HtmlWebpage) SetTitle

func (w *HtmlWebpage) SetTitle(title string) *HtmlWebpage

SetTitle sets the title of the webpage

func (*HtmlWebpage) Style

func (w *HtmlWebpage) Style(style string) *HtmlWebpage

Style shortcut for adding a style

func (*HtmlWebpage) StyleURL

func (w *HtmlWebpage) StyleURL(styleURL string) *HtmlWebpage

StyleURL shortcut for adding a style URL to the webpage

func (*HtmlWebpage) StyleURLs

func (w *HtmlWebpage) StyleURLs(styleURLs []string) *HtmlWebpage

StyleURLs shortcut for adding style URLs to the webpage

func (*HtmlWebpage) ToHTML

func (w *HtmlWebpage) ToHTML() string

ToHTML returns HTML representation of the webpage

type SwalOptions

type SwalOptions struct {
	Background         string `json:"background,omitempty"`
	Backdrop           string `json:"backdrop,omitempty"`
	CancelButtonColor  string `json:"cancelButtonColor,omitempty"`
	CancelButtonText   string `json:"cancelButtonText,omitempty"`
	Color              string `json:"color,omitempty"`
	ConfirmButtonText  string `json:"confirmButtonText,omitempty"`
	ConfirmButtonColor string `json:"confirmButtonColor,omitempty"`
	ConfirmCallback    string `json:"-"`
	DenyButtonText     string `json:"denyButtonText,omitempty"`
	CustomClass        string `json:"customClass,omitempty"`
	Grow               string `json:"grow,omitempty"`
	HeightAuto         bool   `json:"heightAuto,omitempty"`
	HTML               string `json:"html,omitempty"`
	Icon               string `json:"icon,omitempty"`
	IconColor          string `json:"iconColor,omitempty"`
	IconHtml           string `json:"iconHtml,omitempty"`
	ImageURL           string `json:"imageUrl,omitempty"`
	ImageWidth         string `json:"imageWidth,omitempty"`
	ImageHeight        string `json:"imageHeight,omitempty"`
	ImageAlt           string `json:"imageAlt,omitempty"`
	Padding            string `json:"padding,omitempty"`
	Position           string `json:"position,omitempty"`
	ShowCancelButton   bool   `json:"showCancelButton"`
	ShowConfirmButton  bool   `json:"showConfirmButton"`
	ShowDenyButton     bool   `json:"showDenyButton"`
	Text               string `json:"text,omitempty"`
	TimerProgressBar   bool   `json:"timerProgressBar,omitempty"`
	Title              string `json:"title,omitempty"`
	Timer              int    `json:"timer,omitempty"`
	Toast              bool   `json:"toast,omitempty"`
	Width              string `json:"width,omitempty"`

	// The following are not standard Sweetalert2 options, do not export to JSON
	RedirectURL     string `json:"-"`
	RedirectSeconds int    `json:"-"`
}

SwalOptions represents configuration options for SweetAlert2 dialogs See https://sweetalert2.github.io/ for full documentation

type SwapMethod

type SwapMethod string
const (
	SwapInnerHTML   SwapMethod = "innerHTML"
	SwapOuterHTML   SwapMethod = "outerHTML"
	SwapBeforeEnd   SwapMethod = "beforeend"
	SwapAfterEnd    SwapMethod = "afterend"
	SwapBeforeBegin SwapMethod = "beforebegin"
	SwapAfterBegin  SwapMethod = "afterbegin"
	SwapNone        SwapMethod = "none"
)

type Tag

type Tag struct {
	TagName       string
	TagContent    string
	TagAttributes map[string]string
	TagChildren   []TagInterface
}

Tag represents an HTML tag https://developer.mozilla.org/en-US/docs/Web/HTML/Element

func A

func A(children ...TagInterface) *Tag

A is a shortcut to create a new A tag

func Abbr

func Abbr(children ...TagInterface) *Tag

func Address

func Address(children ...TagInterface) *Tag

func Article

func Article(children ...TagInterface) *Tag

func Aside

func Aside(children ...TagInterface) *Tag

func B

func B(children ...TagInterface) *Tag

B is a shortcut to create a new B tag

func BR

func BR() *Tag

BR is a shortcut to create a new BR tag

func Bold

func Bold(children ...TagInterface) *Tag

Bold is a shortcut to create a new B tag

func Br

func Br() *Tag

Br is a lowercase alias for BR

func Button

func Button(children ...TagInterface) *Tag

Button is a shortcut to create a new BUTTON tag

func Canvas

func Canvas(children ...TagInterface) *Tag

Canvas is a shortcut to create a new CANVAS tag

func Caption

func Caption(children ...TagInterface) *Tag

Caption is a shortcut to create a new CAPTION tag

func Code

func Code(children ...TagInterface) *Tag

Code is a shortcut to create a new CODE tag

func Dialog

func Dialog(children ...TagInterface) *Tag

func Div

func Div(children ...TagInterface) *Tag

Div is a shortcut to create a new DIV tag

func FieldSet

func FieldSet(children ...TagInterface) *Tag
func Footer(children ...TagInterface) *Tag

Footer is a shortcut to create a new FOOTER tag

func Form

func Form(children ...TagInterface) *Tag

Form is a shortcut to create a new FORM tag

func H1

func H1(children ...TagInterface) *Tag

H1 is a shortcut to create a new H1 tag

func H2

func H2(children ...TagInterface) *Tag

H2 is a shortcut to create a new H2 tag

func H3

func H3(children ...TagInterface) *Tag

H3 is a shortcut to create a new H3 tag

func H4

func H4(children ...TagInterface) *Tag

H4 is a shortcut to create a new H4 tag

func H5

func H5(children ...TagInterface) *Tag

H5 is a shortcut to create a new H5 tag

func H6

func H6(children ...TagInterface) *Tag

H6 is a shortcut to create a new H6 tag

func HR

func HR() *Tag

HR is a shortcut to create a new HR tag

func Header(children ...TagInterface) *Tag

Header is a shortcut to create a new HEADER tag

func Heading1

func Heading1(children ...TagInterface) *Tag

Heading1 is a shortcut to create a new H1 tag

func Heading2

func Heading2(children ...TagInterface) *Tag

Heading2 is a shortcut to create a new H2 tag

func Heading3

func Heading3(children ...TagInterface) *Tag

Heading3 is a shortcut to create a new H3 tag

func Heading4

func Heading4(children ...TagInterface) *Tag

Heading4 is a shortcut to create a new H4 tag

func Heading5

func Heading5(children ...TagInterface) *Tag

Heading5 is a shortcut to create a new H5 tag

func Heading6

func Heading6(children ...TagInterface) *Tag

Heading6 is a shortcut to create a new H6 tag

func Hr

func Hr() *Tag

Hr is a lowercase alias for HR

func Hyperlink(children ...TagInterface) *Tag

Hyperlink is a shortcut to create a new A tag

func I

func I(children ...TagInterface) *Tag

I is a shortcut to create a new I tag

func Iframe

func Iframe(src string) *Tag

Img is a shortcut to create a new IMG tag

func Image

func Image(src string) *Tag

Image is a shortcut to create a new IMG tag

func Img

func Img(src string) *Tag

Img is a shortcut to create a new IMG tag

func Input

func Input() *Tag

Input is a shortcut to create a new INPUT tag

func LI

func LI(children ...TagInterface) *Tag

LI is a shortcut to create a new LI tag

func Label

func Label(children ...TagInterface) *Tag

Label is a shortcut to create a new LABEL tag

func Li

func Li(children ...TagInterface) *Tag

Li is a lowercase alias for LI

func Link() *Tag

Link is a shortcut to create a new LINK tag

func Main

func Main(children ...TagInterface) *Tag

Main is a shortcut to create a new MAIN tag

func Meta

func Meta() *Tag

Meta is a shortcut to create a new META tag

func Nav(children ...TagInterface) *Tag

Nav is a shortcut to create a new NAV tag

func Navbar(children ...TagInterface) *Tag

Navbar is a shortcut to create a new NAVBAR tag

func NewA

func NewA() *Tag

NewA represents an A tag Shortcut method exists: A()

func NewAbbr

func NewAbbr() *Tag

NewAbbr represents an ABBR tag Shortcut method exists: Abbr()

func NewAddress

func NewAddress() *Tag

NewAddress represents an ADDRESS tag Shortcut method exists: Address()

func NewArticle

func NewArticle() *Tag

NewArticle represents an ARTICLE tag Shortcut method exists: Article()

func NewAside

func NewAside() *Tag

NewAside represents an ASIDE tag Shortcut method exists: Aside()

func NewB

func NewB() *Tag

NewB represents a B tag Shortcut method exists: B()

func NewBR

func NewBR() *Tag

NewBR represents a BR tag Shortcut method exists: BR()

func NewBold

func NewBold() *Tag

NewBold represents a B tag Shortcut method exists: Bold()

func NewButton

func NewButton() *Tag

NewButton represents a BUTTON tag Shortcut method exists: Button()

func NewCanvas

func NewCanvas() *Tag

NewCanvas represents a CANVAS tag Shortcut method exists: Canvas()

func NewCaption

func NewCaption() *Tag

NewCaption is a shortcut to create a new CAPTION tag Shortcut method exists: Caption()

func NewCode

func NewCode() *Tag

NewCode represents a CODE tag Shortcut method exists: Code()

func NewDialog

func NewDialog() *Tag

NewDialog represents a DIALOG tag Shortcut method exists: Dialog()

func NewDiv

func NewDiv() *Tag

NewDiv represents a DIV tag Shortcut method exists: Div()

func NewFieldSet

func NewFieldSet() *Tag

NewFieldSet represents a FIELDSET tag Shortcut method exists: FieldSet()

func NewFigure

func NewFigure() *Tag

NewFigure represents a FIGURE tag Shortcut method exists: Figure()

func NewFooter

func NewFooter() *Tag

NewFooter is a shortcut to create a new FOOTER tag Shortcut method exists: Footer()

func NewForm

func NewForm() *Tag

NewForm represents a FORM tag Shortcut method exists: Form()

func NewH1

func NewH1() *Tag

NewH1 represents a H1 tag Shortcut method exists: H1()

func NewH2

func NewH2() *Tag

NewH2 represents a H2 tag Shortcut method exists: H2()

func NewH3

func NewH3() *Tag

NewH3 represents a H3 tag Shortcut method exists: H3()

func NewH4

func NewH4() *Tag

NewH4 represents a H4 tag Shortcut method exists: H4()

func NewH5

func NewH5() *Tag

NewH5 represents a H5 tag Shortcut method exists: H5()

func NewH6

func NewH6() *Tag

NewH6 represents a H6 tag Shortcut method exists: H6()

func NewHR

func NewHR() *Tag

NewHR creates represents a HR tags Shortcut method exists: HR()

func NewHTML

func NewHTML(html string) *Tag

NewHTML creates pure HTML without surrounding tags for safe escaped outut use NewText() Shortcut method exists: Raw() Deprecated: replaced by the new method NewRaw()

func NewHeader

func NewHeader() *Tag

NewHeader is a shortcut to create a new HEADER tag Deprecated: replaced by the new method Header()

func NewHeading1

func NewHeading1() *Tag

NewHeading1 represents a H1 tag Shortcut method exists: Heading1()

func NewHeading2

func NewHeading2() *Tag

NewHeading2 represents a H2 tag Shortcut method exists: Heading2()

func NewHeading3

func NewHeading3() *Tag

NewHeading3 represents a H3 tag Shortcut method exists: Heading3()

func NewHeading4

func NewHeading4() *Tag

NewHeading4 represents a H4 tag Shortcut method exists: Heading4()

func NewHeading5

func NewHeading5() *Tag

NewHeading5 represents a H5 tag Shortcut method exists: Heading5()

func NewHeading6

func NewHeading6() *Tag

NewHeading6 represents a H6 tag Shortcut method exists: Heading6()

func NewHyperlink() *Tag

NewHyperlink represents a H1 tag Shortcut method exists: Hyperlink()

func NewI

func NewI() *Tag

NewI represents an I tag Shortcut method exists: I()

func NewIframe

func NewIframe() *Tag

NewIframe represents an IFRAME tag Shortcut method exists: Iframe()

func NewImage

func NewImage() *Tag

NewImage represents a IMG tag Shortcut method exists: Image()

func NewImg

func NewImg() *Tag

NewImg represents an IMG tag Shortcut method exists: Img()

func NewInput

func NewInput() *Tag

NewInput represents a IMG tag Shortcut method exists: Input()

func NewLI

func NewLI() *Tag

NewLI represents a LI tag Shortcut method exists: LI()

func NewLabel

func NewLabel() *Tag

NewLabel represents a LABEL tag Shortcut method exists: Label()

func NewLink() *Tag

NewLink represents a LINK tag Shortcut method exists: Link()

func NewMain

func NewMain() *Tag

NewMain represents a MAIN tag Shortcut method exists: Main()

func NewMeta

func NewMeta() *Tag

NewMeta represents a META tag Shortcut method exists: Meta()

func NewNav

func NewNav() *Tag

NewNav represents a NAV tag Shortcut method exists: Nav()

func NewNavbar

func NewNavbar() *Tag

NewNavbar represents a NAVBAR tag Deprecated: replaced by the new method Navbar()

func NewOL

func NewOL() *Tag

NewOL represents a OL tag Shortcut method exists: OL()

func NewOption

func NewOption() *Tag

NewOption represents an OPTION tag Shortcut method exists: Option()

func NewP

func NewP() *Tag

NewP represents a P tag Shortcut method exists: P()

func NewPRE

func NewPRE() *Tag

NewPRE represents a PRE tag Shortcut method exists: PRE()

func NewParagraph

func NewParagraph() *Tag

NewParagraph represents a IMG tag Shortcut method exists: Paragraph()

func NewPod

func NewPod() *Tag

NewPod represents a wrapper tag It serves as a container for other tags, and is used to wrap other tags together. Deprecated: replaced by the new method Wrap()

func NewRaw

func NewRaw(html string) *Tag

NewRaw creates pure escaped HTML without surrounding tags for safe escaped outut use NewText() Shortcut method exists: Raw()

func NewScript

func NewScript(javascript string) *Tag

NewScript represents a SCRIPT tag Shortcut method exists: Script()

func NewScriptURL

func NewScriptURL(javascriptURL string) *Tag

NewScriptURL represents a SCRIPT tag with URL Shortcut method exists: ScriptURL()

func NewSection

func NewSection() *Tag

NewSection represents a SECTION tag Shortcut method exists: Section()

func NewSelect

func NewSelect() *Tag

NewSelect represents a SELECT tag Shortcut method exists: Select()

func NewSmall

func NewSmall() *Tag

NewSmall represents a SMALL tag Shortcut method exists: Small()

func NewSpan

func NewSpan() *Tag

NewSpan represents a SPAN tag Shortcut method exists: Span()

func NewStrong

func NewStrong() *Tag

NewStrong represents a STRONG tag Shortcut method exists: Strong()

func NewStyle

func NewStyle(css string) *Tag

NewStyle represents a STYLE tag Shortcut method exists: Style()

func NewStyleURL

func NewStyleURL(styleURL string) *Tag

NewStyleURL represents a LINK tag with URL Shortcut method exists: StyleURL()

func NewSub

func NewSub() *Tag

NewSub represents a SUB tag Shortcut method exists: Sub()

func NewSup

func NewSup() *Tag

NewSup represents a SUP tag Shortcut method exists: Sup()

func NewTD

func NewTD() *Tag

NewTD represents a TD tag Shortcut method exists: TD()

func NewTH

func NewTH() *Tag

NewTH represents a TH tag Shortcut method exists: TH()

func NewTR

func NewTR() *Tag

NewTR represents a TR tag Shortcut method exists: TR()

func NewTable

func NewTable() *Tag

NewTable represents a TABLE tag Shortcut method exists: Table()

func NewTag

func NewTag(tagName string) *Tag

NewTag creates a tag, with the specified name useful for custom tags or ones that are not yet added to the hb library

func NewTbody

func NewTbody() *Tag

NewTbody represents a TBODY tag Shortcut method exists: Tbody()

func NewTemplate

func NewTemplate() *Tag

NewTemplate represents a TEMPLATE tag Shortcut method exists: Template()

func NewText

func NewText(text string) *Tag

NewText creates pure escaped text without surrounding tags Shortcut method exists: Text()

func NewTextArea

func NewTextArea() *Tag

NewTextArea represents a FORM tag Shortcut method exists: TextArea()

func NewTfoot

func NewTfoot() *Tag

NewTfoot represents a TFOOT tag Shortcut method exists: Tfoot()

func NewThead

func NewThead() *Tag

NewThead represents a THEAD tag Shortcut method exists: Thead()

func NewTitle

func NewTitle() *Tag

NewTitle represents a TITLE tag Shortcut method exists: Title()

func NewUL

func NewUL() *Tag

NewUL represents a UL tag Shortcut method exists: UL()

func NewVideo

func NewVideo() *Tag

NewVideo represents a VIDEO tag Shortcut method exists: Video()

func NewWrap

func NewWrap() *Tag

NewWrap is a convenience tagless container to wrap multiple elements together. Any attributes added to the wrap tag will be lost. If you need to keep these better use a DIV tag Shortcut method exists: Wrap()

func OL

func OL(children ...TagInterface) *Tag

OL is a shortcut to create a new OL tag

func Ol

func Ol(children ...TagInterface) *Tag

Ol is a lowercase alias for OL

func Option

func Option(children ...TagInterface) *Tag

Option is a shortcut to create a new OPTION tag

func P

func P(children ...TagInterface) *Tag

P is a shortcut to create a new P tag

func PRE

func PRE(children ...TagInterface) *Tag

PRE is a shortcut to create a new PRE tag

func Paragraph

func Paragraph(children ...TagInterface) *Tag

Paragraph is a shortcut to create a new P tag

func Raw

func Raw(html string) *Tag

Raw is a shortcut to create a new HTML tag

func Script

func Script(javascript string) *Tag

Script is a shortcut to create a new SCRIPT tag

func ScriptURL

func ScriptURL(javascriptURL string) *Tag

ScriptURL is a shortcut to create a new SCRIPT tag

func Section

func Section(children ...TagInterface) *Tag

Section is a shortcut to create a new SECTION tag

func Select

func Select(children ...TagInterface) *Tag

Select is a shortcut to create a new SELECT tag

func Small

func Small(children ...TagInterface) *Tag

Small is a shortcut to create a new SMALL tag

func Span

func Span(children ...TagInterface) *Tag

Span is a shortcut to create a new SPAN tag

func Strong

func Strong(children ...TagInterface) *Tag

Strong is a shortcut to create a new STRONG tag

func Style

func Style(css string) *Tag

Style is a shortcut to create a new STYLE tag

func StyleURL

func StyleURL(styleURL string) *Tag

StyleURL is a shortcut to create a new STYLE tag

func Sub

func Sub(children ...TagInterface) *Tag

Sub is a shortcut to create a new SUB tag

func Sup

func Sup(children ...TagInterface) *Tag

Sup is a shortcut to create a new SUP tag

func TBody

func TBody(children ...TagInterface) *Tag

TBody is an alternative capitalization alias for Tbody

func TD

func TD(children ...TagInterface) *Tag

TD is a shortcut to create a new TD tag

func TFoot

func TFoot(children ...TagInterface) *Tag

TFoot is an alternative capitalization alias for Tfoot

func TH

func TH(children ...TagInterface) *Tag

TH is a shortcut to create a new TH tag

func THead

func THead(children ...TagInterface) *Tag

THead is an alternative capitalization alias for Thead

func TR

func TR(children ...TagInterface) *Tag

TR is a shortcut to create a new TR tag

func Table

func Table(children ...TagInterface) *Tag

Table is a shortcut to create a new TABLE tag

func Tbody

func Tbody(children ...TagInterface) *Tag

Tbody is a shortcut to create a new TBODY tag

func Td

func Td(children ...TagInterface) *Tag

Td is a lowercase alias for TD

func Template

func Template() *Tag

Template is a shortcut to create a new TEMPLATE tag

func Text

func Text(text string) *Tag

Text creates pure escaped text without surrounding tags to use a raw text use Raw

func TextArea

func TextArea() *Tag

TextArea is a shortcut to create a new TEXTAREA tag

func Textarea

func Textarea() *Tag

Textarea is a lowercase alias for TextArea

func Tfoot

func Tfoot(children ...TagInterface) *Tag

Tfoot is a shortcut to create a new TFOOT tag

func Th

func Th(children ...TagInterface) *Tag

Th is a lowercase alias for TH

func Thead

func Thead(children ...TagInterface) *Tag

Thead is a shortcut to create a new THEAD tag

func Title

func Title(children ...TagInterface) *Tag

Title is a shortcut to create a new title tag

func Tr

func Tr(children ...TagInterface) *Tag

Tr is a lowercase alias for TR

func UL

func UL(children ...TagInterface) *Tag

UL is a shortcut to create a new UL tag

func Ul

func Ul(children ...TagInterface) *Tag

Ul is a lowercase alias for UL

func Wrap

func Wrap(children ...TagInterface) *Tag

Wrap is a convenience tagless container to wrap multiple elements together. Any attributes added to the wrap tag will be lost. If you need to keep these better use a DIV tag

func (*Tag) Action

func (t *Tag) Action(action string) *Tag

Action shortcut for setting the "action" attribute

func (*Tag) AddChild

func (t *Tag) AddChild(child TagInterface) *Tag

AddChild adds a new child tag to this tag

func (*Tag) AddChildren

func (t *Tag) AddChildren(children []TagInterface) *Tag

AddChildren adds an array of child tags to this tag

func (*Tag) AddClass

func (t *Tag) AddClass(className string) *Tag

AddClass adds a new class name to the tag attribute list.

func (*Tag) AddHTML

func (t *Tag) AddHTML(html string) *Tag

AddHTML adds an HTML string as a child tag to this tag

func (*Tag) AddStyle

func (t *Tag) AddStyle(style string) *Tag

AddStyle adds a new style to the tag attribute list.

func (*Tag) AddText

func (t *Tag) AddText(text string) *Tag

AddText adds an escaped text string as a child tag to this tag

func (*Tag) Alt

func (t *Tag) Alt(text string) *Tag

Alt shortcut for setting the "alt" attribute

func (*Tag) Aria

func (t *Tag) Aria(key, value string) *Tag

Aria shortcut for setting an "aria-" attribute

func (*Tag) Attr

func (t *Tag) Attr(key, value string) *Tag

Attr shortcut for SetAttribute

func (*Tag) AttrIf

func (t *Tag) AttrIf(condition bool, key, value string) *Tag

AttrIf shortcut for setting an attribute if a condition is met

func (*Tag) AttrIfElse

func (t *Tag) AttrIfElse(condition bool, key, valueIf, valueElse string) *Tag

AttrIfElse shortcut for setting an attribute if a condition is met, otherwise adds another attribute

func (*Tag) AttrIfF

func (t *Tag) AttrIfF(condition bool, key string, valueFunc func() string) *Tag

func (*Tag) Attrs

func (t *Tag) Attrs(attrs map[string]string) *Tag

Attrs shortcut for setting multiple attributes

func (*Tag) AttrsIf

func (t *Tag) AttrsIf(condition bool, attrs map[string]string) *Tag

AttrsIf shortcut for setting multiple attributes if a condition is met

func (*Tag) AttrsIfElse

func (t *Tag) AttrsIfElse(condition bool, attrsIf, attrsElse map[string]string) *Tag

AttrsIfElse shortcut for setting multiple attributes if a condition is met, otherwise adds another attribute

func (*Tag) AttrsIfF

func (t *Tag) AttrsIfF(condition bool, attrsFunc func() map[string]string) *Tag

AttrsIfF shortcut for setting multiple attributes via function if a condition is met

func (*Tag) Child

func (t *Tag) Child(child TagInterface) *Tag

Child shortcut for AddChild

func (*Tag) ChildIf

func (t *Tag) ChildIf(condition bool, child TagInterface) *Tag

ChildIf adds a child if a condition is met

func (*Tag) ChildIfElse

func (t *Tag) ChildIfElse(condition bool, childIf, childElse TagInterface) *Tag

ChildIfElse adds a child if a condition is met, otherwise adds another child

func (*Tag) ChildIfF

func (t *Tag) ChildIfF(condition bool, childFunc func() TagInterface) *Tag

ChildIfF adds a child using function if a condition is met

func (*Tag) Children

func (t *Tag) Children(children []TagInterface) *Tag

Children shortcut for AddChildren

func (*Tag) ChildrenIf

func (t *Tag) ChildrenIf(condition bool, children []TagInterface) *Tag

ChildrenIf adds children if a condition is met

func (*Tag) ChildrenIfElse

func (t *Tag) ChildrenIfElse(condition bool, childrenIf, childrenElse []TagInterface) *Tag

ChildrenIfElse adds children if a condition is met

func (*Tag) ChildrenIfF

func (t *Tag) ChildrenIfF(condition bool, childrenFunc func() []TagInterface) *Tag

ChildrenIfF adds children using function if a condition is met

func (*Tag) Class

func (t *Tag) Class(className string) *Tag

Class shortcut for setting the "class" attribute

func (*Tag) ClassIf

func (t *Tag) ClassIf(condition bool, className string) *Tag

ClassIf adds class name if a condition is met

func (*Tag) ClassIfElse

func (t *Tag) ClassIfElse(condition bool, classNameIf, classNameElse string) *Tag

ClassIfElse adds class name if a condition is met

func (*Tag) ClassIfF

func (t *Tag) ClassIfF(condition bool, classNameFunc func() string) *Tag

ClassIfF adds class name using function if a condition is met

func (*Tag) Data

func (t *Tag) Data(name, value string) *Tag

Data shortcut for setting a "data-" attribute

func (*Tag) DataIf

func (t *Tag) DataIf(condition bool, name, value string) *Tag

DataIf shortcut for setting a "data-" attribute if a condition is met

func (*Tag) DataIfElse

func (t *Tag) DataIfElse(condition bool, name, valueIf, valueElse string) *Tag

DataIfElse shortcut for setting a "data-" attribute if a condition is met

func (*Tag) Enctype

func (t *Tag) Enctype(enctype string) *Tag

Enctype shortcut for setting the "enctype" attribute

func (*Tag) For

func (t *Tag) For(forID string) *Tag

For shortcut for setting the "for" attribute It is only applicable to the <label> element The value of the for attribute must be a single id for a labelable form-related element in the same document as the <label> element. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label

func (*Tag) GetAttribute

func (t *Tag) GetAttribute(key string) string

GetAttribute returns the value of an attribute

func (*Tag) HTML

func (t *Tag) HTML(html string) *Tag

HTML shortcut for AddHTML

func (*Tag) HTMLIf

func (t *Tag) HTMLIf(condition bool, html string) *Tag

HTMLIf adds html if a condition is met

func (*Tag) HTMLIfElse

func (t *Tag) HTMLIfElse(condition bool, htmlIf, htmlElse string) *Tag

HTMLIfElse adds HTML if a condition is met

func (*Tag) HTMLIfF

func (t *Tag) HTMLIfF(condition bool, htmlFunc func() string) *Tag

HTMLIfF adds html using function if a condition is met

func (*Tag) HasAttribute

func (t *Tag) HasAttribute(key string) bool

HasAttribute returns true if the tag has an attribute with the specified key.

func (*Tag) HasAttributeValue

func (t *Tag) HasAttributeValue(key, value string) bool

HasAttributeValue returns true if the tag has an attribute with the specified value.

func (*Tag) HasClass

func (t *Tag) HasClass(className string) bool

HasClass returns true if the tag has a class with the specified name.

func (*Tag) Href

func (t *Tag) Href(href string) *Tag

Href shortcut for setting the "href" attribute

func (*Tag) Hx

func (t *Tag) Hx(name, value string) *Tag

Hx is a generic method for setting any HTMX attribute Attributes follow the format hx-{NAME}="{VALUE}" Returns the tag for method chaining

func (*Tag) HxConfirm

func (t *Tag) HxConfirm(value string) *Tag

HxConfirm sets the hx-confirm attribute for confirmation dialogs Returns the tag for method chaining

func (*Tag) HxDelete

func (t *Tag) HxDelete(value string) *Tag

HxDelete sets the hx-delete attribute for AJAX DELETE requests Returns the tag for method chaining

func (*Tag) HxGet

func (t *Tag) HxGet(value string) *Tag

HxGet sets the hx-get attribute for AJAX GET requests Returns the tag for method chaining

func (*Tag) HxInclude

func (t *Tag) HxInclude(value string) *Tag

HxInclude sets the hx-include attribute for element inclusion Returns the tag for method chaining

func (*Tag) HxIndicator

func (t *Tag) HxIndicator(value string) *Tag

HxIndicator sets the hx-indicator attribute for loading indicators Returns the tag for method chaining

func (*Tag) HxOn

func (t *Tag) HxOn(name, value string) *Tag

HxOn sets event handlers using the hx-on:{event} attribute Returns the tag for method chaining

func (*Tag) HxPatch

func (t *Tag) HxPatch(value string) *Tag

HxPatch sets the hx-patch attribute for AJAX PATCH requests Returns the tag for method chaining

func (*Tag) HxPost

func (t *Tag) HxPost(value string) *Tag

HxPost sets the hx-post attribute for AJAX POST requests Returns the tag for method chaining

func (*Tag) HxPut

func (t *Tag) HxPut(value string) *Tag

HxPut sets the hx-put attribute for AJAX PUT requests Returns the tag for method chaining

func (*Tag) HxSelect

func (t *Tag) HxSelect(value string) *Tag

HxSelect sets the hx-select attribute for element selection Returns the tag for method chaining

func (*Tag) HxSelectOob

func (t *Tag) HxSelectOob(value string) *Tag

HxSelectOob sets the hx-select-oob attribute for out-of-band selection Returns the tag for method chaining

func (*Tag) HxSwap

func (t *Tag) HxSwap(method SwapMethod) *Tag

HxSwap sets the hx-swap attribute for content swapping Returns the tag for method chaining

func (*Tag) HxSwapOob

func (t *Tag) HxSwapOob(value string) *Tag

HxSwapOob sets the hx-swap-oob attribute for out-of-band swaps Returns the tag for method chaining

func (*Tag) HxSync

func (t *Tag) HxSync(value string) *Tag

HxSync sets the hx-sync attribute for request synchronization Returns the tag for method chaining

func (*Tag) HxTarget

func (t *Tag) HxTarget(value string) *Tag

HxTarget sets the hx-target attribute for request targeting Returns the tag for method chaining

func (*Tag) HxTrigger

func (t *Tag) HxTrigger(value string) *Tag

HxTrigger sets the hx-trigger attribute for event triggering Returns the tag for method chaining

func (*Tag) HxVals

func (t *Tag) HxVals(value string) *Tag

HxVals sets the hx-vals attribute for request values Returns the tag for method chaining

func (*Tag) HxVars

func (t *Tag) HxVars(value string) *Tag

HxVars sets the hx-vars attribute for request variables Returns the tag for method chaining

func (*Tag) ID

func (t *Tag) ID(id string) *Tag

ID shortcut for setting the "id" attribute

func (*Tag) Method

func (t *Tag) Method(method string) *Tag

Method shortcut for setting the "method" attribute

func (*Tag) Name

func (t *Tag) Name(name string) *Tag

Name shortcut for setting the "name" attribute

func (*Tag) OnBlur

func (t *Tag) OnBlur(js string) *Tag

OnBlur shortcut for setting the "onblur" attribute

func (*Tag) OnChange

func (t *Tag) OnChange(js string) *Tag

OnChange shortcut for setting the "onchange" attribute

func (*Tag) OnClick

func (t *Tag) OnClick(js string) *Tag

OnClick shortcut for setting the "onclick" attribute

func (*Tag) OnDblClick

func (t *Tag) OnDblClick(js string) *Tag

OnDblClick shortcut for setting the "ondblclick" attribute

func (*Tag) OnFocus

func (t *Tag) OnFocus(js string) *Tag

OnFocus shortcut for setting the "onfocus" attribute

func (*Tag) OnInput

func (t *Tag) OnInput(js string) *Tag

OnInput shortcut for setting the "oninput" attribute

func (*Tag) OnKeyDown

func (t *Tag) OnKeyDown(js string) *Tag

OnKeyDown shortcut for setting the "onkeydown" attribute

func (*Tag) OnKeyPress

func (t *Tag) OnKeyPress(js string) *Tag

OnKeyPress shortcut for setting the "onkeypress" attribute

func (*Tag) OnKeyUp

func (t *Tag) OnKeyUp(js string) *Tag

OnKeyUp shortcut for setting the "onkeyup" attribute

func (*Tag) OnLoad

func (t *Tag) OnLoad(js string) *Tag

OnLoad shortcut for setting the "onload" attribute

func (*Tag) OnMouseDown

func (t *Tag) OnMouseDown(js string) *Tag

OnMouseDown shortcut for setting the "onmousedown" attribute

func (*Tag) OnMouseEnter

func (t *Tag) OnMouseEnter(js string) *Tag

OnMouseEnter shortcut for setting the "onmouseenter" attribute

func (*Tag) OnMouseLeave

func (t *Tag) OnMouseLeave(js string) *Tag

OnMouseLeave shortcut for setting the "onmouseleave" attribute

func (*Tag) OnMouseMove

func (t *Tag) OnMouseMove(js string) *Tag

OnMouseMove shortcut for setting the "onmousemove" attribute

func (*Tag) OnMouseOut

func (t *Tag) OnMouseOut(js string) *Tag

OnMouseOut shortcut for setting the "onmouseout" attribute

func (*Tag) OnMouseOver

func (t *Tag) OnMouseOver(js string) *Tag

OnMouseOver shortcut for setting the "onmouseover" attribute

func (*Tag) OnMouseUp

func (t *Tag) OnMouseUp(js string) *Tag

OnMouseUp shortcut for setting the "onmouseup" attribute

func (*Tag) OnSubmit

func (t *Tag) OnSubmit(js string) *Tag

OnSubmit shortcut for setting the "onsubmit" attribute

func (*Tag) Placeholder

func (t *Tag) Placeholder(placeholder string) *Tag

Placeholder shortcut for setting the "placeholder" attribute

func (*Tag) ReadOnly

func (t *Tag) ReadOnly(isReadOnly bool) *Tag

ReadOnly shortcut for setting the "readonly" attribute The readonly attribute is supported by text, search, url, tel, email, password, date, month, week, time, datetime-local, and number <input> types and the <textarea> form control elements. https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly

func (*Tag) Rel

func (t *Tag) Rel(rel string) *Tag

Rel shortcut for setting the "rel" attribute The rel attribute defines the relationship between a linked resource and the current document. Valid on <link>, <a>, <area>, and <form>. https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types

func (*Tag) RemoveAttribute

func (t *Tag) RemoveAttribute(key string) *Tag

RemoveAttribute removes an attribute

func (*Tag) Required

func (t *Tag) Required(isRequired bool) *Tag

Required shortcut for setting the "required" attribute The required attribute is supported by text, search, url, tel, email, password, date, month, week, time, datetime-local, number, checkbox, radio, file, <input> types along with the <select> and <textarea> form control elements. https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required

func (*Tag) Role

func (t *Tag) Role(role string) *Tag

Role shortcut for setting the "role" attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA

func (*Tag) Selected

func (t *Tag) Selected(isSelected bool) *Tag

Selected shortcut for setting the "selected" attribute Only applies to the <option> element in a <select>, <optgroup>, or <datalist>. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option

func (*Tag) SetAttribute

func (t *Tag) SetAttribute(key, value string) *Tag

SetAttribute sets the value of an attribute https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes

func (*Tag) Src

func (t *Tag) Src(src string) *Tag

Src shortcut for setting the "src" attribute

func (*Tag) SrcIf

func (t *Tag) SrcIf(condition bool, src string) *Tag

SrcIf sets the "src" attribute if a condition is met

func (*Tag) SrcIfElse

func (t *Tag) SrcIfElse(condition bool, srcIf, srcElse string) *Tag

SrcIfElse sets the "src" attribute based on a condition

func (*Tag) SrcIfF

func (t *Tag) SrcIfF(condition bool, srcFunc func() string) *Tag

SrcIfF sets the "src" attribute using function if a condition is met

func (*Tag) Style

func (t *Tag) Style(style string) *Tag

Style shortcut for setting the "style" attribute

func (*Tag) StyleIf

func (t *Tag) StyleIf(condition bool, style string) *Tag

StyleIf adds style if a condition is met

func (*Tag) StyleIfElse

func (t *Tag) StyleIfElse(condition bool, styleIf, styleElse string) *Tag

StyleIfElse adds style if a condition is met

func (*Tag) StyleIfF

func (t *Tag) StyleIfF(condition bool, styleFunc func() string) *Tag

StyleIfF adds style using function if a condition is met

func (*Tag) Target

func (t *Tag) Target(target string) *Tag

Target shortcut for setting the "target" attribute

func (*Tag) TargetIf

func (t *Tag) TargetIf(condition bool, target string) *Tag

TargetIf sets the target if a condition is met

func (*Tag) TargetIfElse

func (t *Tag) TargetIfElse(condition bool, targetIf, targetElse string) *Tag

TargetIfElse sets the "target" attribute based on a condition

func (*Tag) Text

func (t *Tag) Text(text string) *Tag

Text shortcut for AddText

func (*Tag) TextIf

func (t *Tag) TextIf(condition bool, text string) *Tag

TextIf adds escaped text if a condition is met

func (*Tag) TextIfElse

func (t *Tag) TextIfElse(condition bool, textIf, textElse string) *Tag

TextIfElse adds escaped text if a condition is met

func (*Tag) TextIfF

func (t *Tag) TextIfF(condition bool, textFunc func() string) *Tag

TextIfF adds escaped text using function if a condition is met

func (*Tag) Title

func (t *Tag) Title(title string) *Tag

Title shortcut for setting the "title" attribute

func (*Tag) TitleIf

func (t *Tag) TitleIf(condition bool, title string) *Tag

TitleIf sets the title if a condition is met

func (*Tag) TitleIfElse

func (t *Tag) TitleIfElse(condition bool, titleIf, titleElse string) *Tag

TitleIfElse sets the "title" attribute based on a condition

func (*Tag) ToHTML

func (t *Tag) ToHTML() string

ToHTML returns HTML from Node

func (*Tag) Type

func (t *Tag) Type(inputType string) *Tag

Type shortcut for setting the "type" attribute

func (*Tag) TypeIf

func (t *Tag) TypeIf(condition bool, inputType string) *Tag

TypeIf sets the type if a condition is met

func (*Tag) TypeIfElse

func (t *Tag) TypeIfElse(condition bool, typeIf, typeElse string) *Tag

TypeIfElse sets the "type" attribute based on a condition

func (*Tag) Value

func (t *Tag) Value(value string) *Tag

Value shortcut for setting the "value" attribute

func (*Tag) ValueIf

func (t *Tag) ValueIf(condition bool, value string) *Tag

ValueIf sets the value if a condition is met

func (*Tag) ValueIfElse

func (t *Tag) ValueIfElse(condition bool, valueIf, valueElse string) *Tag

ValueIfElse sets the "value" attribute based on a condition

func (*Tag) X

func (t *Tag) X(name, value string) *Tag

X shortcut for setting an Alpine attribute AlpineJS attributes have the format of x-{NAME}="{VALUE}"

func (*Tag) XBind

func (t *Tag) XBind(name, value string) *Tag

func (*Tag) XOn

func (t *Tag) XOn(name, value string) *Tag

type TagInterface

type TagInterface interface {
	ToHTML() string
}

TagInterface represents an HTML tag interface

func If

func If(condition bool, trueTag TagInterface) TagInterface

func IfElse

func IfElse(condition bool, trueTag, falseTag TagInterface) TagInterface

func IfF

func IfF(condition bool, trueFunc func() TagInterface) TagInterface

func IfFElseF

func IfFElseF(condition bool, trueFunc, falseFunc func() TagInterface) TagInterface

func NewSwal

func NewSwal(options SwalOptions) TagInterface

NewSwal generates a script with a Sweetalert2 dialog Note! you must include the library yourself (i.e. CDN) Shortcut method exists: Swal()

func NewSwalError

func NewSwalError(options SwalOptions) TagInterface

NewSwalError creates a SweetAlert2 error dialog with the provided options

func NewSwalInfo

func NewSwalInfo(options SwalOptions) TagInterface

NewSwalInfo creates a SweetAlert2 info dialog with the provided options

func NewSwalSuccess

func NewSwalSuccess(options SwalOptions) TagInterface

NewSwalSuccess creates a SweetAlert2 success dialog with the provided options

func NewSwalWarning

func NewSwalWarning(options SwalOptions) TagInterface

NewSwalWarning creates a SweetAlert2 warning dialog with the provided options

func Swal

func Swal(options SwalOptions) TagInterface

Swal generates a script with a SweetAlert2 dialog Note! you must include the library yourself (i.e. CDN)

func SwalError

func SwalError(options SwalOptions) TagInterface

SwalError creates a SweetAlert2 error dialog

func SwalInfo

func SwalInfo(options SwalOptions) TagInterface

SwalInfo creates a SweetAlert2 info dialog

func SwalSuccess

func SwalSuccess(options SwalOptions) TagInterface

SwalSuccess creates a SweetAlert2 success dialog

func SwalWarning

func SwalWarning(options SwalOptions) TagInterface

SwalWarning creates a SweetAlert2 warning dialog

func Ternary

func Ternary(condition bool, trueTag, falseTag TagInterface) TagInterface

Ternary is a 1 line if/else statement.

func TernaryF

func TernaryF(condition bool, trueFunc, falseFunc func() TagInterface) TagInterface

TernaryF is a 1 liner if/else statement whose options are functions

func ToTags

func ToTags[T any](items []T, callback func(item T, index int) TagInterface) []TagInterface

ToTags is a functional helper to convert a slice of items to a slice of tags using a callback function

Example:

items := []string{"one", "two", "three"}

tags := ToTags(items, func(item string, index int) TagInterface {
  return NewSpan().Text(item)
})

Output: <span>one</span><span>two</span><span>three</span>

Parameters: - items: The slice of items to convert to tags - callback: A function that takes an item and index and returns a TagInterface

Returns: - []TagInterface: A slice of tags

Jump to

Keyboard shortcuts

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