html

package
v0.1.83 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// EscapeString is alias of [html.EscapeString],
	// used for encoding HTML entities.
	EscapeString = html.EscapeString
	// UnescapeString is alias of [html.UnescapeString],
	// used for decoding HTML entities.
	UnescapeString = html.UnescapeString
)

Functions

This section is empty.

Types

type Element

type Element struct {
	// contains filtered or unexported fields
}

Element represents a single HTML element, including its tag name, attributes, and inner HTML content.

func A

func A() *Element

func B

func B() *Element

func Background

func Background() *Element

Background creates an element with no tag, typically used for raw content.

func Body

func Body() *Element

func Br

func Br() *Element

func Div

func Div() *Element

func Em

func Em() *Element

func Form

func Form() *Element

func H1

func H1() *Element

func H2

func H2() *Element
func Head() *Element

func I

func I() *Element

func Img

func Img() *Element

func Input

func Input() *Element

func Label

func Label() *Element

func Li

func Li() *Element

func Meta

func Meta() *Element

func NewElement

func NewElement(tag string) *Element

NewElement creates and returns a new HTML element with the given tag name.

func NewHTML

func NewHTML() *Element

NewHTML creates a new <html> element.

func P

func P() *Element

func Span

func Span() *Element

func Style

func Style() *Element

func Svg

func Svg() *Element

func Table

func Table() *Element

func Tbody

func Tbody() *Element

func Thead

func Thead() *Element

func Title

func Title() *Element

func Tr

func Tr(element ...*TableCell) *Element

Tr creates a new <tr> element containing the given table cells.

func Ul

func Ul() *Element

func (*Element) AppendChild

func (e *Element) AppendChild(child ...*Element) *Element

AppendChild appends child elements to the current element.

func (*Element) AppendContent

func (e *Element) AppendContent(v ...any) *Element

AppendContent appends additional content to the element.

func (*Element) AppendHTML

func (e *Element) AppendHTML(html ...string) *Element

AppendHTML appends one or more raw HTML strings directly to the element.

func (*Element) Attribute

func (e *Element) Attribute(name, value string) *Element

Attribute sets or updates an attribute on the element. If attrs is nil, it initializes the map.

func (*Element) Class

func (e *Element) Class(class ...string) *Element

Class sets the "class" attribute. Multiple classes can be provided.

func (*Element) Clone added in v0.1.81

func (e *Element) Clone() *Element

Clone creates a deep copy of the element and its attributes.

func (*Element) Content

func (e *Element) Content(v ...any) *Element

Content replaces the current content of the element with new values.

func (*Element) Contentf

func (e *Element) Contentf(format string, a ...any) *Element

Contentf formats a string using fmt.Sprintf and sets it as the element content.

func (*Element) HTML

func (e *Element) HTML() HTML

HTML returns the element as HTML type, implementing HTMLer.

func (*Element) HTMLContent

func (e *Element) HTMLContent(html string) *Element

HTMLContent inserts raw (unescaped) HTML into the element content.

func (*Element) Href

func (e *Element) Href(href string) *Element

Href sets the "href" attribute.

func (*Element) Name

func (e *Element) Name(name string) *Element

Name sets the "name" attribute.

func (*Element) Src

func (e *Element) Src(src string) *Element

Src sets the "src" attribute.

func (*Element) String

func (e *Element) String() string

String returns the serialized HTML representation of the element.

func (*Element) Style

func (e *Element) Style(style string) *Element

Style sets the "style" attribute.

func (*Element) Title

func (e *Element) Title(title string) *Element

Title sets the "title" attribute.

type HTML

type HTML string

HTML represents a string that contains valid HTML markup.

type HTMLer

type HTMLer interface {
	HTML() HTML
}

HTMLer defines types that can render themselves as HTML.

type TableCell

type TableCell struct{ *Element }

TableCell wraps an Element and provides methods specific to <td> and <th> cells.

func Td

func Td(content any) *TableCell

Td creates a new <td> (table data cell) element with optional content.

func Th

func Th(content any) *TableCell

Th creates a new <th> (table header cell) element with optional content.

func (*TableCell) Abbr

func (cell *TableCell) Abbr(abbr string) *TableCell

Abbr sets the "abbr" attribute on the table cell.

func (*TableCell) Class

func (cell *TableCell) Class(class ...string) *TableCell

Class sets the "class" attribute for the table cell.

func (*TableCell) Colspan

func (cell *TableCell) Colspan(n uint) *TableCell

Colspan sets the "colspan" attribute, specifying how many columns the cell spans.

func (*TableCell) Headers

func (cell *TableCell) Headers(headers string) *TableCell

Headers sets the "headers" attribute, linking the cell to header IDs.

func (*TableCell) Rowspan

func (cell *TableCell) Rowspan(n uint) *TableCell

Rowspan sets the "rowspan" attribute, specifying how many rows the cell spans.

func (*TableCell) Scope

func (cell *TableCell) Scope(scope string) *TableCell

Scope sets the "scope" attribute, typically used in <th> to define scope of headers.

func (*TableCell) Style

func (cell *TableCell) Style(style string) *TableCell

Style sets the "style" attribute for the table cell.

Jump to

Keyboard shortcuts

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