Documentation
¶
Index ¶
- Variables
- func Base64Data(str string, mime string, data string) *element
- func DataURL(str string, mime string, data string) *element
- func Download(str string, href string, filename string) *element
- func FTP(url string, str string) *element
- func JumpTo(anchor string, str string) *element
- func Link(href string, str string) *element
- func MailTo(email string, str string) *element
- func New(nodes ...node.Node) *element
- func RawText(str string) *element
- func RawTextf(format string, args ...any) *element
- func SMS(number string, str string) *element
- func Static(str string) *element
- func Tel(number string, str string) *element
- func Text(str string) *element
- func Textf(format string, args ...any) *element
- type Element
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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>