slot

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

	AttrName = []byte(" name=\"")
)

Byte constants for HTML rendering.

Functions

func Named added in v0.3.0

func Named(name string, nodes ...node.Node) *element

Named Creates a named slot with fallback child content. Named slots receive content from elements with a matching slot attribute in the web component's light DOM. Example: slot.Named("header", p.Text("Default header")) Renders: <slot name="header"><p>Default header</p></slot>

func New

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

New Creates a new slot element with optional child nodes. Example: slot.New() Renders: <slot></slot>

func RawText

func RawText(str string) *element

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

func RawTextf

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

RawTextf Creates a new slot element with formatted raw fallback text content. Uses text.RawTextf which is not HTML-escaped. Example: slot.RawTextf("<em>%s</em> content", title) Renders: <slot><em>Dashboard</em> content</slot>

func Static

func Static(str string) *element

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

func Text

func Text(str string) *element

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

func Textf

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

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

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