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 attr DOM Node. If one parameter is passed, it's a name-only attribute (like "required"). If two parameters are passed, it's a name-value attribute (like `class="header"`). More parameter counts make Attr panic. Use this if no convenience creator exists.
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. Use this if no convenience creator exists. 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 nodes are ignored.
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 attr provides shortcuts and helpers to common HTML attributes.
|
Package attr provides shortcuts and helpers to common HTML attributes. |
Package components provides high-level components that are composed of low-level elements and attributes.
|
Package components provides high-level components that are composed of low-level elements and attributes. |
Package el provides shortcuts and helpers to common HTML elements.
|
Package el provides shortcuts and helpers to common HTML elements. |
examples
|
|