Documentation
¶
Overview ¶
Package slot provides constructors and methods for the HTML <slot> element.
The <slot> HTML element is a placeholder inside a web component that you can fill with your own markup, which lets you create separate DOM trees and present them together.
Index ¶
- Variables
- func Named(name string, nodes ...node.Node) *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("<slot") TagClose = []byte("</slot>") AttrName = []byte(" name=\"") )
Byte constants for HTML rendering.
Functions ¶
func Named ¶ added in v0.3.0
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 ¶
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 ¶
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>