Documentation ¶
Index ¶
- type Builder
- func (b *Builder) A(href string) *Element
- func (b *Builder) B(class string) *Element
- func (b *Builder) BR() *Element
- func (b *Builder) Button() *Element
- func (builder *Builder) Bytes() []byte
- func (builder *Builder) Close() *Builder
- func (builder *Builder) CloseAll() *Builder
- func (builder *Builder) Container(name string) *Element
- func (b *Builder) Datalist(id string) *Element
- func (b *Builder) Div() *Element
- func (builder *Builder) Element(name string, container bool) *Element
- func (builder *Builder) Empty(name string) *Element
- func (builder *Builder) EndBracket() *Builder
- func (b *Builder) Form(method string, action string) *Element
- func (b *Builder) H1() *Element
- func (b *Builder) H2() *Element
- func (b *Builder) H3() *Element
- func (b *Builder) I(classes ...string) *Element
- func (b *Builder) Input(t string, name string) *Element
- func (b *Builder) Label(forID string) *Element
- func (b *Builder) Link(rel string, href string) *Element
- func (b *Builder) OptGroup(label string) *Element
- func (b *Builder) Option(name string, value string) *Element
- func (builder *Builder) ReadString() string
- func (builder *Builder) Reader() io.Reader
- func (b *Builder) Script() *Element
- func (b *Builder) Select(name string) *Element
- func (builder *Builder) Space() *Builder
- func (b *Builder) Span() *Element
- func (builder *Builder) String() string
- func (b *Builder) Stylesheet(url string) *Element
- func (builder *Builder) SubTree() *Builder
- func (b *Builder) TD() *Element
- func (b *Builder) TH() *Element
- func (b *Builder) TR() *Element
- func (b *Builder) Table() *Element
- func (b *Builder) Textarea(name string) *Element
- type Element
- func (element *Element) Aria(name string, value string) *Element
- func (element *Element) Attr(name string, value string) *Element
- func (element *Element) Class(values ...string) *Element
- func (element *Element) Close() *Element
- func (element *Element) Data(name string, value string) *Element
- func (element *Element) EndBracket() *Element
- func (element *Element) For(value string) *Element
- func (element *Element) Href(url string) *Element
- func (element *Element) ID(value string) *Element
- func (element *Element) InnerHTML(innerHTML string) *Element
- func (element *Element) Label(value string) *Element
- func (element *Element) List(value string) *Element
- func (element *Element) Name(value string) *Element
- func (element *Element) Rel(value string) *Element
- func (element *Element) Role(value string) *Element
- func (element *Element) Script(value string) *Element
- func (element *Element) Src(value string) *Element
- func (element *Element) Start() *Element
- func (element *Element) Style(values ...string) *Element
- func (element *Element) TabIndex(value string) *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) EndBracket ¶ added in v0.11.2
EndBracket adds an end bracket to the last tag on the stack
func (*Builder) ReadString ¶ added in v0.12.1
ReadString reads the existing contents of the buffer but DOES NOT close any existing tags. This is useful for reading the header of an HTML document before calling a subroutine that will fill in its body.
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) Stylesheet ¶ added in v0.12.1
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) Class ¶ added in v0.9.0
Class adds a "class" attribute to the Element. Multiple class names can be passed, and are separated by spaces
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) Rel ¶ added in v0.12.1
Name adds a "rel" (relationship) attribute to the Element (valid values listed at https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel)
func (*Element) Script ¶ added in v0.10.0
Script adds a "data-script" attribute to the Element (for https://hyperscript.org)
func (*Element) Start ¶ added in v0.9.0
Start writes the initial tag name and opening bracket for this tag.
func (*Element) Style ¶ added in v0.11.2
Stype adds a "style" attribute to the Element Multiple style definitions can be passed, and are separated by semicolons.