Documentation
¶
Overview ¶
Package elem provides types and utils for node elements.
The core abstractions are:
Element utils include:
- New: Produces an element, returns a Scope to complete with child elements (e.g. <div>scope goes here</div>).
- Void: A self-closing element (e.g., <br/>, <img/>).
- Raw: Raw document content (text, HTML).
- Scope: A function to call to fill in child elements.
- Bundle: A slice of multiple elements.
- Seq: A sequence of multiple elements.
- Cons: A head element followed by a tail of elements.
- Noop: An empty element that produces no output.
- If: A conditional element.
- IfElse: A choice between elements.
- Fn: A dynamically produced element.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bundle ¶
type Bundle []Node
Bundle is a slice of elements. These elements will be rendered adjacent to each other.
type Node ¶
func Cons ¶
Cons is a functional convenience for producing a sequence of elements: starting with the head element, followed by the tail elements. These elements will be rendered adjacent to each other.
type Obj ¶
type Obj struct {
// Tag is the element tag name. Empty for raw content or bundles.
Tag string
// Raw is pre-rendered HTML content (used for raw/comment nodes).
// When set, Tag is a sentinel (e.g. "RAW", "COMMENT") to avoid squashing.
Raw string
// Void indicates a self-closing element (e.g. <br/>, <input/>).
Void bool
// Attribs holds the element's attributes.
Attribs attr.Seq
// Children holds the element's child elements.
Children iter.Seq[Node]
}
Obj is the evaluated representation of an element.
type Scope ¶
Scope is returned by non-void element constructors. Call it with child elements to produce an elem.Node. It also implements elem.Node directly (evaluates with no children).
Click to show internal directories.
Click to hide internal directories.