Documentation
¶
Overview ¶
Package iframe provides constructors and methods for the HTML <iframe> element.
The <iframe> HTML element represents a nested browsing context, embedding another HTML page within the current document. Creates an isolated environment for displaying external content, third-party widgets, embedded applications, or sandboxed content. Supports various security controls via sandbox and permissions attributes. Common uses include embedded videos, maps, payment forms, and external content integration.
Index ¶
- Variables
- func Eager(src string) *element
- func Lazy(src string) *element
- func New(nodes ...node.Node) *element
- func RawText(str string) *element
- func RawTextf(format string, args ...any) *element
- func Static(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("<iframe") TagClose = []byte("</iframe>") AttrSrc = []byte(" src=\"") AttrWidth = []byte(" width=\"") AttrHeight = []byte(" height=\"") AttrLoading = []byte(" loading=\"") AttrAllow = []byte(" allow=\"") AttrAllowFullscreen = []byte(" allowfullscreen") AttrName = []byte(" name=\"") AttrReferrerPolicy = []byte(" referrerpolicy=\"") AttrSandbox = []byte(" sandbox=\"") AttrSrcDoc = []byte(" srcdoc=\"") AttrCsp = []byte(" csp=\"") AttrCredentialless = []byte(" credentialless") )
Byte constants for HTML rendering.
Functions ¶
func Eager ¶
func Eager(src string) *element
Eager creates an iframe element with eager loading for immediate content display. Example: iframe.Eager("/critical-content.html") Renders: <iframe src="/critical-content.html" loading="eager"></iframe> Note: Iframe loads immediately, regardless of viewport position
func Lazy ¶
func Lazy(src string) *element
Lazy creates an iframe element with lazy loading enabled for improved performance. Example: iframe.Lazy("/page.html") Renders: <iframe src="/page.html" loading="lazy"></iframe> Note: Iframe will only load when it enters or is near the viewport
func New ¶
New creates a new iframe element with optional fallback content. Example: iframe.New().Src("/page.html") Renders: <iframe src="/page.html"></iframe>
func RawText ¶
func RawText(str string) *element
RawText creates a new iframe element with raw fallback content. Uses text.RawText which is not HTML-escaped. Example: iframe.RawText("<p>Fallback content</p>") Renders: <iframe><p>Fallback content</p></iframe>
func RawTextf ¶
RawTextf creates a new iframe element with formatted raw fallback content. Uses text.RawTextf which is not HTML-escaped. Example: iframe.RawTextf("<p>Loading <strong>%s</strong>...</p>", page) Renders: <iframe><p>Loading <strong>Home</strong>...</p></iframe>
func Static ¶
func Static(str string) *element
Static creates a new iframe element with static fallback text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: iframe.Static("Loading embedded content...") Renders: <iframe>Loading embedded content...</iframe>