Documentation ¶
Index ¶
- type Builder
- func (b *Builder) BR() *Element
- func (builder *Builder) Close() *Builder
- func (builder *Builder) CloseAll() *Builder
- func (builder *Builder) Container(name string) *Element
- func (b *Builder) Div() *Element
- func (builder *Builder) Element(name string, container bool) *Element
- func (builder *Builder) Empty(name string) *Element
- func (b *Builder) Input() *Element
- func (b *Builder) Label(forID string) *Element
- func (b *Builder) Span() *Element
- func (builder *Builder) String() string
- func (builder *Builder) SubTree() *Builder
- type Element
- func (element *Element) Attr(name string, value interface{}) *Element
- func (element *Element) Class(value string) *Element
- func (element *Element) Close() *Element
- func (element *Element) EndBracket() *Element
- func (element *Element) For(value string) *Element
- func (element *Element) ID(value string) *Element
- func (element *Element) InnerHTML(innerHTML string) *Element
- func (element *Element) Name(value string) *Element
- func (element *Element) Start() *Element
- func (element *Element) Type(value string) *Element
- func (element *Element) Value(value string) *Element
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶ added in v0.9.0
Builder collects tags and attributes into a strings.Builder efficiently.
func (*Builder) Close ¶ added in v0.9.0
Close completes the last tag on the stack, then pops it off of the stack
func (*Builder) Container ¶ added in v0.9.0
Container creates a new "container" element that WILL have an end tag.
func (*Builder) Empty ¶ added in v0.9.0
Empty creates a new "empty" or non-container element that WILL NOT have an end tag
func (*Builder) String ¶ added in v0.9.0
String returns the assembled HTML as a string. It overrides the default behavior of the strings.Builder by also calling CloseAll() on all unclosed tags in the stack before generating HTML.
func (*Builder) SubTree ¶ added in v0.9.0
SubTree generates a new Builder that shares this Builder's string buffer. This is useful when sending a Builder to another function, so that the other function can maintain it's own stack of elements -- and potentially call .CloseAll() -- without affecting this current builder.
type Element ¶ added in v0.9.0
type Element struct {
// contains filtered or unexported fields
}
Element represents a element that is being written into the provided strings.Builder
func (*Element) Attr ¶ added in v0.9.0
Attr writes the attribute into the string builder. It converts the value (second parameter) into a string, and then uses html.EscapeString to escape the attribute value. Attribute names ARE NOT escaped.
func (*Element) Close ¶ added in v0.9.0
Close writes the necessary closing tag for this element and marks it closed
func (*Element) EndBracket ¶ added in v0.9.0
EndBracket writes the final ">" of the beginning element to the strings.Builder It uses an internal variable to prevent duplicate calls
func (*Element) InnerHTML ¶ added in v0.9.0
InnerHTML does three things: 1) closes the beginning element (if needed) 2) appends innerHTML (if provided) 3) writes an ending element to the builder (ie. </element> )
func (*Element) Start ¶ added in v0.9.0
Start writes the initial tag name and opening bracket for this tag.