Documentation ¶
Overview ¶
Package gomponents provides declarative view components in Go, that can render to HTML5. The primary interface is a Node, which has a single function Render, which should render the Node to a string. Furthermore, NodeFunc is a function which implements the Node interface by calling itself on Render. All DOM elements and attributes can be created by using the El and Attr functions. The package also provides a lot of convenience functions for creating elements and attributes with the most commonly used parameters. If they don't suffice, a fallback to El and Attr is always possible.
Index ¶
Constants ¶
const ( ElementType = NodeType(iota) AttributeType )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
Node is a DOM node that can Render itself to a io.Writer.
func Attr ¶
Attr creates an attribute DOM Node with a name and optional value. If only a name is passed, it's a name-only (boolean) attribute (like "required"). If a name and value are passed, it's a name-value attribute (like `class="header"`). More than one value make Attr panic. Use this if no convenience creator exists.
func Group ¶ added in v0.7.0
Group multiple Nodes into one Node. Useful for concatenation of Nodes in variadic functions. The resulting Node cannot Render directly, trying it will panic. Render must happen through a parent element created with El or a helper.
type NodeFunc ¶
NodeFunc is render function that is also a Node of ElementType.
func El ¶
El creates an element DOM Node with a name and child Nodes. See https://dev.w3.org/html5/spec-LC/syntax.html#elements-0 for how elements are rendered. No tags are ever omitted from normal tags, even though it's allowed for elements given at https://dev.w3.org/html5/spec-LC/syntax.html#optional-tags If an element is a void kind, non-attribute children nodes are ignored. Use this if no convenience creator exists.
func Textf ¶ added in v0.4.0
Textf creates a text DOM Node that Renders the interpolated and escaped string t.
Directories ¶
Path | Synopsis |
---|---|
Package assert provides testing helpers.
|
Package assert provides testing helpers. |
Package components provides high-level components and helpers that are composed of low-level elements and attributes.
|
Package components provides high-level components and helpers that are composed of low-level elements and attributes. |
examples
|
|
Package html provides common HTML elements and attributes.
|
Package html provides common HTML elements and attributes. |