iframe

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 24 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

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

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

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

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>

func Text

func Text(str string) *element

Text creates a new iframe element with fallback text content. Uses text.Text which HTML-escapes the output. Example: iframe.Text("Your browser does not support iframes.") Renders: <iframe>Your browser does not support iframes.</iframe>

func Textf

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

Textf creates a new iframe element with formatted fallback text content. Uses text.Textf which HTML-escapes the output. Example: iframe.Textf("Loading %s...", page) Renders: <iframe>Loading Home...</iframe>

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