a

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: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

	AttrHref           = []byte(" href=\"")
	AttrAttributionSrc = []byte(" attributionsrc=\"")
	AttrDownload       = []byte(" download=\"")
	AttrHrefLang       = []byte(" hreflang=\"")
	AttrPing           = []byte(" ping=\"")
	AttrReferrerPolicy = []byte(" referrerpolicy=\"")
	AttrRel            = []byte(" rel=\"")
	AttrTarget         = []byte(" target=\"")
	AttrType           = []byte(" type=\"")
)

Byte constants for HTML rendering.

Functions

func Base64Data

func Base64Data(str string, mime string, data string) *element

Base64Data Creates a new anchor element with base64 data URL for binary content downloads Example: a.Base64Data("Download Image", "image/png", "iVBORw0KGgoAAAANS...") Renders: <a href="data:image/png;base64,iVBORw0KGgoAAAANS...">Download Image</a>

func DataURL

func DataURL(str string, mime string, data string) *element

DataURL Creates a new anchor element with data URL for embedded content or downloads Example: a.DataURL("Download Text", "text/plain", "Hello%20World") Renders: <a href="data:text/plain,Hello%20World">Download Text</a>

func Download added in v0.3.0

func Download(str string, href string, filename string) *element

Download Creates a download link that prompts the user to save the linked resource rather than navigating to it. The filename parameter suggests a name for the saved file, though the user can override it. Uses text.Text which HTML-escapes the link text. Example: a.Download("Get the report", "/files/report.pdf", "report.pdf") Renders: <a href="/files/report.pdf" download="report.pdf">Get the report</a>

func FTP

func FTP(url string, str string) *element

FTP Creates a new anchor element with FTP protocol Example: a.FTP("files.example.com/folder", "Download Files") Renders: <a href="ftp://files.example.com/folder">Download Files</a>

func JumpTo

func JumpTo(anchor string, str string) *element

JumpTo Creates a new anchor element for internal page navigation (fragment identifier) Example: a.JumpTo("section1", "Go to Section 1") Renders: <a href="#section1">Go to Section 1</a>

func Link(href string, str string) *element

Link Creates a new anchor element with href and text content Example: a.Link("https://example.com", "Click here") Renders: <a href="https://example.com">Click here</a>

func MailTo

func MailTo(email string, str string) *element

MailTo Creates a new anchor element with mailto scheme that opens the user's email client Example: a.MailTo("john@example.com", "Email John") Renders: <a href="mailto:john@example.com">Email John</a>

func New

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

New Creates a new anchor element without any initial attributes. Example: a.New(text.Text("Click here")).Href("https://example.com") Renders: <a href="https://example.com">Click here</a>

func RawText

func RawText(str string) *element

RawText Creates a new anchor element with raw text content. Uses text.RawText which is not HTML-escaped. Example: a.RawText("Click <em>here</em>") Renders: <a>Click <em>here</em></a>

func RawTextf

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

RawTextf Creates a new anchor element with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: a.RawTextf("Hello <em>%s</em>", name) Renders: <a>Hello <em>Mary</em></a>

func SMS

func SMS(number string, str string) *element

SMS Creates a new anchor element with SMS scheme that opens the messaging app on mobile devices Example: a.SMS("+1234567890", "Send SMS") Renders: <a href="sms:+1234567890">Send SMS</a>

func Static

func Static(str string) *element

Static Creates a new anchor element with static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: a.Static("Click here") Renders: <a>Click here</a>

func Tel

func Tel(number string, str string) *element

Tel Creates a new anchor element with tel scheme that initiates a phone call on mobile devices Example: a.Tel("+1234567890", "Call Me") Renders: <a href="tel:+1234567890">Call Me</a>

func Text

func Text(str string) *element

Text Creates a new anchor element with text content. Uses text.Text which HTML-escapes the output. Example: a.Text("Click here") Renders: <a>Click here</a>

func Textf

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

Textf Creates a new anchor element with formatted text content. Uses text.Textf which HTML-escapes the output. Example: a.Textf("Hello %s", name) Renders: <a>Hello Mary</a>

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