html

package
v0.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen  = []byte("<html")
	TagClose = []byte("</html>")

	AttrLang     = []byte(" lang=\"")
	AttrXmlns    = []byte(" xmlns=\"")
	AttrManifest = []byte(" manifest=\"")
)

Byte constants for HTML rendering.

Functions

func Fragment

func Fragment(nodes ...node.Node) *element

Fragment Creates an html fragment without DOCTYPE declaration (for fragments or embedded use) Example: html.Fragment() Renders: <html></html>

func FragmentRawText

func FragmentRawText(str string) *element

FragmentRawText Creates an html fragment without DOCTYPE declaration with raw text content. Uses text.RawText which is not HTML-escaped. Example: html.FragmentRawText("<body>Content</body>") Renders: <html><body>Content</body></html>

func FragmentRawTextf

func FragmentRawTextf(format string, args ...any) *element

FragmentRawTextf Creates an html fragment without DOCTYPE declaration with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: html.FragmentRawTextf("<body><h1>%s</h1></body>", title) Renders: <html><body><h1>Dashboard</h1></body></html>

func FragmentStatic

func FragmentStatic(str string) *element

FragmentStatic Creates an html fragment without DOCTYPE declaration with static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: html.FragmentStatic("Fragment content") Renders: <html>Fragment content</html>

func FragmentText

func FragmentText(str string) *element

FragmentText Creates an html fragment without DOCTYPE declaration with text content. Uses text.Text which HTML-escapes the output. Example: html.FragmentText("Content") Renders: <html>Content</html>

func FragmentTextf

func FragmentTextf(format string, args ...any) *element

FragmentTextf Creates an html fragment without DOCTYPE declaration with formatted text content. Uses text.Textf which HTML-escapes the output. Example: html.FragmentTextf("Page for %s", name) Renders: <html>Page for Mary</html>

func New

func New(nodes ...node.Node) *element

New Creates a complete HTML5 document with DOCTYPE declaration Example: html.New() Renders: <!DOCTYPE html><html></html>

func RawText

func RawText(str string) *element

RawText Creates a complete HTML5 document with DOCTYPE declaration and raw text content. Uses text.RawText which is not HTML-escaped. Example: html.RawText("<body>Content</body>") Renders: <!DOCTYPE html><html><body>Content</body></html>

func RawTextf

func RawTextf(format string, args ...any) *element

RawTextf Creates a complete HTML5 document with DOCTYPE declaration and formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: html.RawTextf("<body><h1>%s</h1></body>", title) Renders: <!DOCTYPE html><html><body><h1>Dashboard</h1></body></html>

func Static

func Static(str string) *element

Static Creates a complete HTML5 document with DOCTYPE declaration and static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: html.Static("Minimal page") Renders: <!DOCTYPE html><html>Minimal page</html>

func Text

func Text(str string) *element

Text Creates a complete HTML5 document with DOCTYPE declaration and text content. Uses text.Text which HTML-escapes the output. Example: html.Text("Content") Renders: <!DOCTYPE html><html>Content</html>

func Textf

func Textf(format string, args ...any) *element

Textf Creates a complete HTML5 document with DOCTYPE declaration and formatted text content. Uses text.Textf which HTML-escapes the output. Example: html.Textf("Page for %s", name) Renders: <!DOCTYPE html><html>Page for Mary</html>

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

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