Documentation ¶
Index ¶
- Variables
- func Script(format string, args ...interface{}) template.HTML
- func Url(format string, args ...interface{}) string
- type Element
- func A(href string, children ...Node) *Element
- func B(children ...Node) *Element
- func BODY() *Element
- func BUTTON(children ...Node) *Element
- func CAPTION(children ...Node) *Element
- func COLGROUP(span int, cols ...*Void) *Element
- func DD(children ...Node) *Element
- func DIV(children ...Node) *Element
- func DL(children ...Node) *Element
- func DT(children ...Node) *Element
- func FOOTER(children ...Node) *Element
- func FORM(method, action string, children ...Node) *Element
- func H1(children ...Node) *Element
- func H2(children ...Node) *Element
- func H3(children ...Node) *Element
- func H4(children ...Node) *Element
- func H5(children ...Node) *Element
- func H6(children ...Node) *Element
- func HEAD() *Element
- func LABEL(For string, children ...Node) *Element
- func LI(children ...Node) *Element
- func MAP(name string, children ...Node) *Element
- func NAV(children ...Node) *Element
- func NOSCRIPT(children ...Node) *Element
- func OBJECT(children ...Node) *Element
- func OL(children ...Node) *Element
- func OPTGROUP(label string, children ...*Element) *Element
- func OPTION(value, text string) *Element
- func P(children ...Node) *Element
- func PRE(children ...Node) *Element
- func RB(children ...Node) *Element
- func RP(children ...Node) *Element
- func RT(children ...Node) *Element
- func RTC(children ...Node) *Element
- func RUBY(children ...Node) *Element
- func SCRIPT(src string, content string) *Element
- func SELECT(children ...*Element) *Element
- func SMALL(children ...Node) *Element
- func SPAN(children ...Node) *Element
- func TABLE(children ...*Element) *Element
- func TBODY(trs ...*Element) *Element
- func TD(children ...Node) *Element
- func TEXTAREA(name, value string, children ...Node) *Element
- func TFOOT(trs ...*Element) *Element
- func TH(children ...Node) *Element
- func THEAD(trs ...*Element) *Element
- func TITLE(title string) *Element
- func TR(children ...*Element) *Element
- func UL(children ...Node) *Element
- func (e *Element) Attr(name string, value string) *Element
- func (e *Element) Child(el ...Node) *Element
- func (e *Element) ChildEls(els ...*Element) *Element
- func (e *Element) ChildVoids(vs ...*Void) *Element
- func (t *Element) Children() []Element
- func (e *Element) NonEmptyAttr(name string, value string) *Element
- func (e *Element) T(txt string) *Element
- func (e *Element) WriteTo(b Writer, opt RenderOptions, parent *Element, childIndex int)
- type HTMLNode
- type HTMLNodeSet
- type Html
- func (h Html) Body() *Element
- func (h Html) Css(href string) Html
- func (h Html) Favicon(href, tp string) Html
- func (h Html) Head() *Element
- func (h Html) Lang(lang string) Html
- func (h Html) SCRIPT(src string, content string) Html
- func (h Html) Title(title string) Html
- func (h Html) Type() TagType
- func (h Html) WriteTo(b Writer, opt RenderOptions, parent *Element, childIndex int)
- type Node
- type RenderOptions
- type Void
- func AREA(href, alt string, shape string, coords []int) *Void
- func BASE(href, target string) *Void
- func BR() *Void
- func COL(span int) *Void
- func EMBED(src URL, tp string, width, height int) *Void
- func HR() *Void
- func IMG(src URL, alt string) *Void
- func INPUT(tp, name, value string) *Void
- func LINK(href, rel string) *Void
- func META() *Void
- func PARAM(name, value string) *Void
- func (v *Void) AddClass(classes ...string) *Void
- func (v *Void) Attr(name string, value string) *Void
- func (v *Void) AttrIfNotEmpty(name, value string) *Void
- func (v *Void) DelClass(classes ...string) *Void
- func (t *Void) ID(id string) *Void
- func (v *Void) Name() HTMLNode
- func (v *Void) NonEmptyAttr(name, value string) *Void
- func (v *Void) TabIndex(tablInex int)
- func (v *Void) Title(title string)
- func (v *Void) Type() TagType
- func (v *Void) WriteTo(b Writer, opt RenderOptions, parent *Element, childIndex int)
- type Writer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // HTML Character Entity copyright COPY = HTMLNode("©") // HTML Character Entity ampersand AMP = HTMLNode("&") // HTML Character Entity less than LT = HTMLNode("<") // HTML Character Entity greater than GT = HTMLNode(">") // HTML Character Entity cent CENT = HTMLNode("¢") // HTML Character Entity pound POUND = HTMLNode("£") // HTML Character Entity yen YEN = HTMLNode("¥") // HTML Character Entity euro EURO = HTMLNode("€") // HTML Character Entity registered trademark REG = HTMLNode("®") // HTML Character Entity non-breaking space NBSP = HTMLNode(" ") TIMES = HTMLNode("×") LAQUO = HTMLNode("«") RAQUO = HTMLNode("»") )
HTML Entities
View Source
var Default = RenderOptions{}
Functions ¶
Types ¶
type Element ¶
type Element struct { Void // contains filtered or unexported fields }
func COLGROUP ¶
The colgroup element
If span > 0, cols are ignored. Otherwise, cols (col tags) are appended as children.
func MAP ¶
The map element.
Example ¶
h := HTML("") body := h.Body() body.Child(MAP("menu", AREA("fun.html", "Fun", "circle", []int{1, 2, 3, 4}))) fmt.Println(NodeToHTMLBytes(h, RenderOptions{SortAttr: true}))
Output: <!DOCTYPE html> <meta charset="utf-8"><map name="menu"><area alt="Fun" coords="12,3,4," href="fun.html" shape="circle"></map>
func TABLE ¶
The table element
Example ¶
h := HTML("") body := h.Body() body.Child(TABLE( CAPTION(T("Hello")), COLGROUP(0, COL(2), COL(1), ), COLGROUP(5), THEAD( TR(TH()), ), TBODY( TR(TD()), ), TFOOT(), )) fmt.Println(NodeToHTMLBytes(h, RenderOptions{SortAttr: true}))
Output: <!DOCTYPE html> <meta charset="utf-8"><table><caption>Hello</caption><col span="2"><col><colgroup span="5"><thead><tr><th><tbody><tr><td><tfoot></table>
func (*Element) ChildVoids ¶
type HTMLNode ¶
type HTMLNode string
Text
func NodeToHTMLBytes ¶
func NodeToHTMLBytes(el Node, opt RenderOptions) HTMLNode
type HTMLNodeSet ¶
type HTMLNodeSet []HTMLNode
func (*HTMLNodeSet) Del ¶
func (set *HTMLNodeSet) Del(s HTMLNode)
func (*HTMLNodeSet) Put ¶
func (set *HTMLNodeSet) Put(s HTMLNode)
type Html ¶
type Html struct {
Element
}
Example ¶
h := HTML("") fmt.Println(NodeToHTMLBytes(h, RenderOptions{DisableOmit: true, SortAttr: true}))
Output: <!DOCTYPE html> <html><head><meta charset="utf-8"></head><body></body></html>
type Node ¶
type Node interface { Type() TagType WriteTo(b Writer, opt RenderOptions, parent *Element, childIndex int) }
type RenderOptions ¶
type Void ¶
type Void struct {
// contains filtered or unexported fields
}
An HTML void element
func BASE ¶
The base element
Example ¶
h := HTML("") head := h.Head() head.Child(BASE("/images", "_blank")) fmt.Println(NodeToHTMLBytes(h, RenderOptions{SortAttr: true}))
Output: <!DOCTYPE html> <meta charset="utf-8"><base href="/images" target="_blank">
func EMBED ¶
The embed element.
tp is the type attribute. Empty string will be ignored. width or height with a negative value will be ignored.
Example ¶
h := HTML("") h.Body().Child( EMBED(URL("http://example.com/a.swf"), "flash", 100, 200), EMBED(URL("http://example.com/a.swf"), "", -1, -1), ) fmt.Println(NodeToHTMLBytes(h, RenderOptions{SortAttr: true}))
Output: <!DOCTYPE html> <meta charset="utf-8"><embed height="200" src="http://example.com/a.swf" type="flash" width="100"><embed src="http://example.com/a.swf">
func HR ¶
func HR() *Void
The br element
Example ¶
h := HTML("") h.Body().Child(HR()) fmt.Println(NodeToHTMLBytes(h, RenderOptions{SortAttr: true}))
Output: <!DOCTYPE html> <meta charset="utf-8"><hr>
func (*Void) AttrIfNotEmpty ¶
func (*Void) NonEmptyAttr ¶
Click to show internal directories.
Click to hide internal directories.