hb

package module
v1.87.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: MIT Imports: 8 Imported by: 0

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/gouniverse/hb"

// or, regular import, and type hb.* before using it each time
// import "github.com/gouniverse/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/gouniverse/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 added in v1.81.0

func TestTagOption(t *testing.T)

func TestTagPRE added in v1.81.0

func TestTagPRE(t *testing.T)

func TestTagSelect added in v1.81.0

func TestTagSelect(t *testing.T)

Types

type BorderLayout added in v1.37.0

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

func NewBorderLayout() *BorderLayout

func (*BorderLayout) AddBottom added in v1.37.0

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

func (*BorderLayout) AddCenter added in v1.37.0

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

func (*BorderLayout) AddLeft added in v1.37.0

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

func (*BorderLayout) AddRight added in v1.37.0

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

func (*BorderLayout) AddTop added in v1.37.0

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

func (*BorderLayout) SetHeightPercents added in v1.37.0

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

func (*BorderLayout) SetHeightPixels added in v1.37.0

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

func (*BorderLayout) SetWidthPercents added in v1.37.0

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

func (*BorderLayout) SetWidthPixels added in v1.37.0

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

func (*BorderLayout) ToHTML added in v1.37.0

func (bl *BorderLayout) ToHTML() string

BorderLayout returns HTML representation of the layout

type HtmlWebpage added in v1.73.4

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

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

AddChild adds a tag to the webpage

func (*HtmlWebpage) AddChildren added in v1.73.4

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

AddChildren adds tags to the webpage

func (*HtmlWebpage) AddHTML added in v1.73.4

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

AddHTML adds an HTML to the body of the webpage

func (*HtmlWebpage) AddMeta added in v1.73.4

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

func (*HtmlWebpage) AddScript added in v1.73.4

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

AddScript adds a script to the webpage

func (*HtmlWebpage) AddScriptURL added in v1.73.4

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

AddScriptURL adds a style URL to the webpage

func (*HtmlWebpage) AddScriptURLs added in v1.73.4

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

AddScriptURLs adds style URLs to the webpage

func (*HtmlWebpage) AddScripts added in v1.73.4

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

AddScripts adds scripts to the webpage

func (*HtmlWebpage) AddStyle added in v1.73.4

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

AddStyle adds a style to the webpage

func (*HtmlWebpage) AddStyleURL added in v1.73.4

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

AddStyleURL adds a style URL to the webpage

func (*HtmlWebpage) AddStyleURLs added in v1.73.4

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

AddStyleURLs adds style URLs to the webpage

func (*HtmlWebpage) AddStyles added in v1.73.4

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

AddStyles adds styles to the webpage

func (*HtmlWebpage) Attr added in v1.73.4

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

Attr shortcut for SetAttribute

func (*HtmlWebpage) Attrs added in v1.73.4

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

Attrs shortcut for setting multiple attributes

func (*HtmlWebpage) Body added in v1.73.4

func (w *HtmlWebpage) Body() *Tag

Body returns a pointer to the body tag

func (*HtmlWebpage) Child added in v1.73.4

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

AddChild shortcut for AddChild

func (*HtmlWebpage) Children added in v1.73.4

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

Children shortcut for AddChildren

func (*HtmlWebpage) HTML added in v1.73.4

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

HTML shortcut for adding HTML to the body

func (*HtmlWebpage) Head added in v1.73.4

func (w *HtmlWebpage) Head() *Tag

Head returns a pointer to the head tag

func (*HtmlWebpage) Meta added in v1.73.4

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

Meta shortcut for adding a meta

func (*HtmlWebpage) Script added in v1.73.4

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

Script shortcut for adding a script

func (*HtmlWebpage) ScriptURL added in v1.73.4

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

ScriptURL shortcut for adding a script URL

func (*HtmlWebpage) ScriptURLs added in v1.73.4

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

ScriptURLs shortcut for adding script URLs

func (*HtmlWebpage) SetAttribute added in v1.73.4

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

SetAttribute adds a style to the webpage

func (*HtmlWebpage) SetCharset added in v1.73.4

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

SetCharset sets the charset of the webpage

func (*HtmlWebpage) SetFavicon added in v1.73.4

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

SetFavicon sets the favicon of the webpage

func (*HtmlWebpage) SetLanguage added in v1.73.4

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

SetLanguage sets the language of the webpage

func (*HtmlWebpage) SetTitle added in v1.73.4

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

SetTitle sets the title of the webpage

func (*HtmlWebpage) Style added in v1.73.4

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

Style shortcut for adding a style

func (*HtmlWebpage) StyleURL added in v1.73.4

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

StyleURL shortcut for adding a style URL to the webpage

func (*HtmlWebpage) StyleURLs added in v1.73.4

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

StyleURLs shortcut for adding style URLs to the webpage

func (*HtmlWebpage) ToHTML added in v1.73.4

func (w *HtmlWebpage) ToHTML() string

ToHTML returns HTML representation of the webpage

type SwalOptions added in v1.68.0

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

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

func A(children ...TagInterface) *Tag

A is a shortcut to create a new A tag

func Abbr added in v1.77.4

func Abbr(children ...TagInterface) *Tag

func Address added in v1.77.4

func Address(children ...TagInterface) *Tag

func Article added in v1.77.4

func Article(children ...TagInterface) *Tag

func Aside added in v1.77.4

func Aside(children ...TagInterface) *Tag

func B added in v1.73.4

func B(children ...TagInterface) *Tag

B is a shortcut to create a new B tag

func BR added in v1.73.4

func BR() *Tag

BR is a shortcut to create a new BR tag

func Bold added in v1.73.4

func Bold(children ...TagInterface) *Tag

Bold is a shortcut to create a new B tag

func Br added in v1.85.0

func Br() *Tag

Br is a lowercase alias for BR

func Button added in v1.73.4

func Button(children ...TagInterface) *Tag

Button is a shortcut to create a new BUTTON tag

func Canvas added in v1.78.0

func Canvas(children ...TagInterface) *Tag

Canvas is a shortcut to create a new CANVAS tag

func Caption added in v1.73.4

func Caption(children ...TagInterface) *Tag

Caption is a shortcut to create a new CAPTION tag

func Code added in v1.73.4

func Code(children ...TagInterface) *Tag

Code is a shortcut to create a new CODE tag

func Dialog added in v1.77.4

func Dialog(children ...TagInterface) *Tag

func Div added in v1.73.4

func Div(children ...TagInterface) *Tag

Div is a shortcut to create a new DIV tag

func FieldSet added in v1.77.4

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

Footer is a shortcut to create a new FOOTER tag

func Form added in v1.73.4

func Form(children ...TagInterface) *Tag

Form is a shortcut to create a new FORM tag

func H1 added in v1.73.4

func H1(children ...TagInterface) *Tag

H1 is a shortcut to create a new H1 tag

func H2 added in v1.73.4

func H2(children ...TagInterface) *Tag

H2 is a shortcut to create a new H2 tag

func H3 added in v1.73.4

func H3(children ...TagInterface) *Tag

H3 is a shortcut to create a new H3 tag

func H4 added in v1.73.4

func H4(children ...TagInterface) *Tag

H4 is a shortcut to create a new H4 tag

func H5 added in v1.73.4

func H5(children ...TagInterface) *Tag

H5 is a shortcut to create a new H5 tag

func H6 added in v1.73.4

func H6(children ...TagInterface) *Tag

H6 is a shortcut to create a new H6 tag

func HR added in v1.73.4

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

func Heading1(children ...TagInterface) *Tag

Heading1 is a shortcut to create a new H1 tag

func Heading2 added in v1.73.4

func Heading2(children ...TagInterface) *Tag

Heading2 is a shortcut to create a new H2 tag

func Heading3 added in v1.73.4

func Heading3(children ...TagInterface) *Tag

Heading3 is a shortcut to create a new H3 tag

func Heading4 added in v1.73.4

func Heading4(children ...TagInterface) *Tag

Heading4 is a shortcut to create a new H4 tag

func Heading5 added in v1.73.4

func Heading5(children ...TagInterface) *Tag

Heading5 is a shortcut to create a new H5 tag

func Heading6 added in v1.73.4

func Heading6(children ...TagInterface) *Tag

Heading6 is a shortcut to create a new H6 tag

func Hr added in v1.85.0

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

func I(children ...TagInterface) *Tag

I is a shortcut to create a new I tag

func Iframe added in v1.73.4

func Iframe(src string) *Tag

Img is a shortcut to create a new IMG tag

func Image added in v1.73.4

func Image(src string) *Tag

Image is a shortcut to create a new IMG tag

func Img added in v1.73.4

func Img(src string) *Tag

Img is a shortcut to create a new IMG tag

func Input added in v1.73.4

func Input() *Tag

Input is a shortcut to create a new INPUT tag

func LI added in v1.73.4

func LI(children ...TagInterface) *Tag

LI is a shortcut to create a new LI tag

func Label added in v1.73.4

func Label(children ...TagInterface) *Tag

Label is a shortcut to create a new LABEL tag

func Li added in v1.85.0

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

func Main(children ...TagInterface) *Tag

Main is a shortcut to create a new MAIN tag

func Meta added in v1.73.4

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

func NewA() *Tag

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

func NewAbbr added in v1.85.0

func NewAbbr() *Tag

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

func NewAddress added in v1.85.0

func NewAddress() *Tag

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

func NewArticle added in v1.85.0

func NewArticle() *Tag

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

func NewAside added in v1.85.0

func NewAside() *Tag

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

func NewB added in v1.85.0

func NewB() *Tag

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

func NewBR added in v1.43.0

func NewBR() *Tag

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

func NewBold added in v1.85.0

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

func NewCanvas() *Tag

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

func NewCaption added in v1.64.0

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

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

func NewFieldSet() *Tag

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

func NewFigure added in v1.85.0

func NewFigure() *Tag

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

func NewFooter added in v1.46.0

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

func NewH1() *Tag

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

func NewH2 added in v1.79.0

func NewH2() *Tag

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

func NewH3 added in v1.79.0

func NewH3() *Tag

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

func NewH4 added in v1.79.0

func NewH4() *Tag

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

func NewH5 added in v1.79.0

func NewH5() *Tag

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

func NewH6 added in v1.79.0

func NewH6() *Tag

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

func NewHR added in v1.31.0

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

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

func NewI() *Tag

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

func NewIframe added in v1.85.0

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

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

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

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

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

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

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

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

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

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

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

func NewVideo() *Tag

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

func NewWrap added in v1.56.0

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

func OL(children ...TagInterface) *Tag

OL is a shortcut to create a new OL tag

func Ol added in v1.85.0

func Ol(children ...TagInterface) *Tag

Ol is a lowercase alias for OL

func Option added in v1.73.4

func Option(children ...TagInterface) *Tag

Option is a shortcut to create a new OPTION tag

func P added in v1.73.4

func P(children ...TagInterface) *Tag

P is a shortcut to create a new P tag

func PRE added in v1.73.4

func PRE(children ...TagInterface) *Tag

PRE is a shortcut to create a new PRE tag

func Paragraph added in v1.73.4

func Paragraph(children ...TagInterface) *Tag

Paragraph is a shortcut to create a new P tag

func Raw added in v1.73.4

func Raw(html string) *Tag

Raw is a shortcut to create a new HTML tag

func Script added in v1.73.4

func Script(javascript string) *Tag

Script is a shortcut to create a new SCRIPT tag

func ScriptURL added in v1.73.4

func ScriptURL(javascriptURL string) *Tag

ScriptURL is a shortcut to create a new SCRIPT tag

func Section added in v1.73.4

func Section(children ...TagInterface) *Tag

Section is a shortcut to create a new SECTION tag

func Select added in v1.73.4

func Select(children ...TagInterface) *Tag

Select is a shortcut to create a new SELECT tag

func Small added in v1.86.0

func Small(children ...TagInterface) *Tag

Small is a shortcut to create a new SMALL tag

func Span added in v1.73.4

func Span(children ...TagInterface) *Tag

Span is a shortcut to create a new SPAN tag

func Strong added in v1.73.4

func Strong(children ...TagInterface) *Tag

Strong is a shortcut to create a new STRONG tag

func Style added in v1.73.4

func Style(css string) *Tag

Style is a shortcut to create a new STYLE tag

func StyleURL added in v1.73.4

func StyleURL(styleURL string) *Tag

StyleURL is a shortcut to create a new STYLE tag

func Sub added in v1.73.4

func Sub(children ...TagInterface) *Tag

Sub is a shortcut to create a new SUB tag

func Sup added in v1.73.4

func Sup(children ...TagInterface) *Tag

Sup is a shortcut to create a new SUP tag

func TBody added in v1.76.3

func TBody(children ...TagInterface) *Tag

TBody is an alternative capitalization alias for Tbody

func TD added in v1.73.4

func TD(children ...TagInterface) *Tag

TD is a shortcut to create a new TD tag

func TFoot added in v1.85.0

func TFoot(children ...TagInterface) *Tag

TFoot is an alternative capitalization alias for Tfoot

func TH added in v1.73.4

func TH(children ...TagInterface) *Tag

TH is a shortcut to create a new TH tag

func THead added in v1.76.3

func THead(children ...TagInterface) *Tag

THead is an alternative capitalization alias for Thead

func TR added in v1.73.4

func TR(children ...TagInterface) *Tag

TR is a shortcut to create a new TR tag

func Table added in v1.73.4

func Table(children ...TagInterface) *Tag

Table is a shortcut to create a new TABLE tag

func Tbody added in v1.73.4

func Tbody(children ...TagInterface) *Tag

Tbody is a shortcut to create a new TBODY tag

func Td added in v1.85.0

func Td(children ...TagInterface) *Tag

Td is a lowercase alias for TD

func Template added in v1.73.4

func Template() *Tag

Template is a shortcut to create a new TEMPLATE tag

func Text added in v1.73.4

func Text(text string) *Tag

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

func TextArea added in v1.73.4

func TextArea() *Tag

TextArea is a shortcut to create a new TEXTAREA tag

func Textarea added in v1.85.0

func Textarea() *Tag

Textarea is a lowercase alias for TextArea

func Tfoot added in v1.73.4

func Tfoot(children ...TagInterface) *Tag

Tfoot is a shortcut to create a new TFOOT tag

func Th added in v1.85.0

func Th(children ...TagInterface) *Tag

Th is a lowercase alias for TH

func Thead added in v1.73.4

func Thead(children ...TagInterface) *Tag

Thead is a shortcut to create a new THEAD tag

func Title added in v1.77.4

func Title(children ...TagInterface) *Tag

Title is a shortcut to create a new title tag

func Tr added in v1.85.0

func Tr(children ...TagInterface) *Tag

Tr is a lowercase alias for TR

func UL added in v1.73.4

func UL(children ...TagInterface) *Tag

UL is a shortcut to create a new UL tag

func Ul added in v1.85.0

func Ul(children ...TagInterface) *Tag

Ul is a lowercase alias for UL

func Wrap added in v1.73.4

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

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

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

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

AddStyle adds a new style to the tag attribute list.

func (*Tag) AddText added in v1.69.0

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

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

func (*Tag) Alt added in v1.57.0

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

Alt shortcut for setting the "alt" attribute

func (*Tag) Aria added in v1.79.0

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

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

AttrIf shortcut for setting an attribute if a condition is met

func (*Tag) AttrIfElse added in v1.54.0

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

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

func (*Tag) Attrs added in v1.32.0

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

Attrs shortcut for setting multiple attributes

func (*Tag) AttrsIf added in v1.54.0

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

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

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

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

Child shortcut for AddChild

func (*Tag) ChildIf added in v1.50.0

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

ChildIf adds a child if a condition is met

func (*Tag) ChildIfElse added in v1.51.0

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

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

ChildIfF adds a child using function if a condition is met

func (*Tag) Children added in v1.41.0

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

Children shortcut for AddChildren

func (*Tag) ChildrenIf added in v1.50.0

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

ChildrenIf adds children if a condition is met

func (*Tag) ChildrenIfElse added in v1.51.0

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

ChildrenIfElse adds children if a condition is met

func (*Tag) ChildrenIfF added in v1.57.0

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

ChildrenIfF adds children using function if a condition is met

func (*Tag) Class added in v1.36.0

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

Class shortcut for setting the "class" attribute

func (*Tag) ClassIf added in v1.50.0

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

ClassIf adds class name if a condition is met

func (*Tag) ClassIfElse added in v1.51.0

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

ClassIfElse adds class name if a condition is met

func (*Tag) ClassIfF added in v1.85.0

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

ClassIfF adds class name using function if a condition is met

func (*Tag) Data added in v1.49.0

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

Data shortcut for setting a "data-" attribute

func (*Tag) DataIf added in v1.55.0

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

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

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

Enctype shortcut for setting the "enctype" attribute

func (*Tag) For added in v1.80.0

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

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

HTMLIf adds html if a condition is met

func (*Tag) HTMLIfElse added in v1.51.0

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

HTMLIfElse adds HTML if a condition is met

func (*Tag) HTMLIfF added in v1.85.0

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

HTMLIfF adds html using function if a condition is met

func (*Tag) HasAttribute added in v1.85.0

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

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

func (*Tag) HasAttributeValue added in v1.85.0

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

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

func (*Tag) HasClass added in v1.36.0

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

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

func (*Tag) Href added in v1.48.0

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

Href shortcut for setting the "href" attribute

func (*Tag) Hx added in v1.48.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

ID shortcut for setting the "id" attribute

func (*Tag) Method added in v1.48.0

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

Method shortcut for setting the "method" attribute

func (*Tag) Name added in v1.48.0

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

Name shortcut for setting the "name" attribute

func (*Tag) OnBlur added in v1.48.0

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

OnBlur shortcut for setting the "onblur" attribute

func (*Tag) OnChange added in v1.48.0

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

OnChange shortcut for setting the "onchange" attribute

func (*Tag) OnClick added in v1.37.0

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

OnClick shortcut for setting the "onclick" attribute

func (*Tag) OnDblClick added in v1.55.0

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

OnDblClick shortcut for setting the "ondblclick" attribute

func (*Tag) OnFocus added in v1.48.0

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

OnFocus shortcut for setting the "onfocus" attribute

func (*Tag) OnInput added in v1.55.0

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

OnInput shortcut for setting the "oninput" attribute

func (*Tag) OnKeyDown added in v1.48.0

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

OnKeyDown shortcut for setting the "onkeydown" attribute

func (*Tag) OnKeyPress added in v1.55.0

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

OnKeyPress shortcut for setting the "onkeypress" attribute

func (*Tag) OnKeyUp added in v1.48.0

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

OnKeyUp shortcut for setting the "onkeyup" attribute

func (*Tag) OnLoad added in v1.55.0

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

OnLoad shortcut for setting the "onload" attribute

func (*Tag) OnMouseDown added in v1.55.0

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

OnMouseDown shortcut for setting the "onmousedown" attribute

func (*Tag) OnMouseEnter added in v1.55.0

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

OnMouseEnter shortcut for setting the "onmouseenter" attribute

func (*Tag) OnMouseLeave added in v1.55.0

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

OnMouseLeave shortcut for setting the "onmouseleave" attribute

func (*Tag) OnMouseMove added in v1.55.0

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

OnMouseMove shortcut for setting the "onmousemove" attribute

func (*Tag) OnMouseOut added in v1.55.0

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

OnMouseOut shortcut for setting the "onmouseout" attribute

func (*Tag) OnMouseOver added in v1.55.0

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

OnMouseOver shortcut for setting the "onmouseover" attribute

func (*Tag) OnMouseUp added in v1.55.0

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

OnMouseUp shortcut for setting the "onmouseup" attribute

func (*Tag) OnSubmit added in v1.55.0

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

OnSubmit shortcut for setting the "onsubmit" attribute

func (*Tag) Placeholder added in v1.54.0

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

Placeholder shortcut for setting the "placeholder" attribute

func (*Tag) ReadOnly added in v1.80.0

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

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

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

RemoveAttribute removes an attribute

func (*Tag) Required added in v1.80.0

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

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

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

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

Src shortcut for setting the "src" attribute

func (*Tag) SrcIf added in v1.63.0

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

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

func (*Tag) SrcIfElse added in v1.85.0

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

SrcIfElse sets the "src" attribute based on a condition

func (*Tag) SrcIfF added in v1.85.0

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

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

Style shortcut for setting the "style" attribute

func (*Tag) StyleIf added in v1.52.0

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

StyleIf adds style if a condition is met

func (*Tag) StyleIfElse added in v1.52.0

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

StyleIfElse adds style if a condition is met

func (*Tag) StyleIfF added in v1.85.0

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

StyleIfF adds style using function if a condition is met

func (*Tag) Target added in v1.48.0

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

Target shortcut for setting the "target" attribute

func (*Tag) TargetIf added in v1.63.0

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

TargetIf sets the target if a condition is met

func (*Tag) TargetIfElse added in v1.85.0

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

TargetIfElse sets the "target" attribute based on a condition

func (*Tag) Text added in v1.69.0

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

Text shortcut for AddText

func (*Tag) TextIf added in v1.69.0

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

TextIf adds escaped text if a condition is met

func (*Tag) TextIfElse added in v1.69.0

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

TextIfElse adds escaped text if a condition is met

func (*Tag) TextIfF added in v1.85.0

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

TextIfF adds escaped text using function if a condition is met

func (*Tag) Title added in v1.72.0

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

Title shortcut for setting the "title" attribute

func (*Tag) TitleIf added in v1.72.0

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

TitleIf sets the title if a condition is met

func (*Tag) TitleIfElse added in v1.85.0

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

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

Type shortcut for setting the "type" attribute

func (*Tag) TypeIf added in v1.63.0

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

TypeIf sets the type if a condition is met

func (*Tag) TypeIfElse added in v1.85.0

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

TypeIfElse sets the "type" attribute based on a condition

func (*Tag) Value added in v1.48.0

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

Value shortcut for setting the "value" attribute

func (*Tag) ValueIf added in v1.63.0

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

ValueIf sets the value if a condition is met

func (*Tag) ValueIfElse added in v1.85.0

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

ValueIfElse sets the "value" attribute based on a condition

func (*Tag) X added in v1.64.0

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

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

func (*Tag) XOn added in v1.64.0

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

type TagInterface

type TagInterface interface {
	ToHTML() string
}

TagInterface represents an HTML tag interface

func If added in v1.50.0

func If(condition bool, trueTag TagInterface) TagInterface

func IfElse added in v1.50.0

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

func IfF added in v1.62.1

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

func IfFElseF added in v1.62.1

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

func NewSwal added in v1.68.0

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

func NewSwalError(options SwalOptions) TagInterface

NewSwalError creates a SweetAlert2 error dialog with the provided options

func NewSwalInfo added in v1.85.0

func NewSwalInfo(options SwalOptions) TagInterface

NewSwalInfo creates a SweetAlert2 info dialog with the provided options

func NewSwalSuccess added in v1.85.0

func NewSwalSuccess(options SwalOptions) TagInterface

NewSwalSuccess creates a SweetAlert2 success dialog with the provided options

func NewSwalWarning added in v1.85.0

func NewSwalWarning(options SwalOptions) TagInterface

NewSwalWarning creates a SweetAlert2 warning dialog with the provided options

func Swal added in v1.73.4

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

func SwalError(options SwalOptions) TagInterface

SwalError creates a SweetAlert2 error dialog

func SwalInfo added in v1.85.0

func SwalInfo(options SwalOptions) TagInterface

SwalInfo creates a SweetAlert2 info dialog

func SwalSuccess added in v1.85.0

func SwalSuccess(options SwalOptions) TagInterface

SwalSuccess creates a SweetAlert2 success dialog

func SwalWarning added in v1.85.0

func SwalWarning(options SwalOptions) TagInterface

SwalWarning creates a SweetAlert2 warning dialog

func Ternary added in v1.70.0

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

Ternary is a 1 line if/else statement.

func TernaryF added in v1.70.0

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

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

func ToTags added in v1.80.1

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