Documentation
¶
Index ¶
- type Attribute
- type Html
- func (h *Html) AddAttribute(name string, value interface{}) *Html
- func (h *Html) AddAttributes(attributes []map[string]interface{}) *Html
- func (h *Html) AddChild(child interface{}) *Html
- func (h *Html) AddChildren(children []interface{}) *Html
- func (h *Html) AddData(data map[string]string) *Html
- func (h *Html) AddHtml(child *Html) *Html
- func (h *Html) AddHtmlChildren(children []*Html) *Html
- func (h *Html) AddId(id string) *Html
- func (h *Html) AddString(str string) *Html
- func (h *Html) AddStringChildren(strings []string) *Html
- func (h *Html) GetAttribute(name string) *Attribute
- func (h *Html) GetAttributes() []*Attribute
- func (h *Html) GetChildren() []interface{}
- func (h *Html) GetName() string
- func (h *Html) IsEmpty() bool
- func (h *Html) RemoveAttribute(name string) *Html
- func (h *Html) RemoveAttributes(names []string) *Html
- func (h *Html) RemoveChildren() *Html
- func (h *Html) Render(level ...int) string
- func (h *Html) UpdateEmpty() *Html
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute struct {
// contains filtered or unexported fields
}
func NewAttribute ¶
NewAttribute create new attribute for html element
func (*Attribute) GetValueString ¶
GetValueString convert value to string
type Html ¶
type Html struct {
// contains filtered or unexported fields
}
func (*Html) AddAttribute ¶
AddAttribute add attribute to element Example:
el := El("div")
el.AddAttribute("class", "container")
func (*Html) AddAttributes ¶
AddAttributes add attributes to element Example:
el := El("div")
el.AddAttributes([]map[string]interface{}{
{"class": "container"},
{"id": "main"},
})
func (*Html) AddChildren ¶
AddChildren add mixed children to element
func (*Html) AddData ¶ added in v1.0.1
AddData add attributes with prefix data-* to element Example:
el := El("div")
el.AddData(map[string][string{"level": "35",})
func (*Html) AddHtml ¶
AddHtml add html child to element Example:
el := El("div")
child := El("p").AddString("some text")
el.AddHtml(child)
func (*Html) AddHtmlChildren ¶
AddHtmlChildren add html children to element Example:
el := El("div")
p := El("p").AddString("some text")
div := El("div")
children := []*html.Html{div, p}
el.AddHtmlChildren(children)
func (*Html) AddId ¶ added in v1.0.4
AddId add id attribute to element Example:
el := El("div")
el.AddId("root")
func (*Html) AddString ¶
AddString add html children to element Example:
p := El("p").AddString("some text")
func (*Html) AddStringChildren ¶
AddStringChildren add string children to element Example:
el := El("div")
children := []string{"some text", "<p>another text</p>"}
el.AddHtmlChildren(children)
func (*Html) GetAttribute ¶
GetAttribute get single attribute of element
func (*Html) GetAttributes ¶
GetAttributes get attributes of element
func (*Html) GetChildren ¶
func (h *Html) GetChildren() []interface{}
GetChildren get html children of element
func (*Html) RemoveAttribute ¶
RemoveAttribute remove attribute from element
func (*Html) RemoveAttributes ¶
RemoveAttributes remove multiple attributes from element
func (*Html) RemoveChildren ¶
RemoveChildren clear children node of element
func (*Html) Render ¶
Render render html to string Example:
el := El("div")
children := []string{"some text", "<p>another text</p>"}
el.AddHtmlChildren(children)
html := el.Render()
func (*Html) UpdateEmpty ¶
UpdateEmpty update element status pair