Documentation ¶
Index ¶
- Constants
- Variables
- func Render(elements ...interface{}) string
- type Attribute
- type BaseComponent
- type Component
- type ListAttribute
- func (attr *ListAttribute) Add(vals ...string) string
- func (attr *ListAttribute) Contains(v string) bool
- func (attr *ListAttribute) Key(keys ...string) string
- func (attr *ListAttribute) Namespace(namespaces ...string) string
- func (attr *ListAttribute) Remove(vals ...string) string
- func (attr *ListAttribute) Separator(s string) Attribute
- func (attr *ListAttribute) String() string
- func (attr *ListAttribute) Val(vals ...string) string
- type StringAttribute
- func (attr *StringAttribute) Add(vals ...string) string
- func (attr *StringAttribute) Key(keys ...string) string
- func (attr *StringAttribute) Namespace(namespaces ...string) string
- func (attr *StringAttribute) Remove(vals ...string) string
- func (attr *StringAttribute) Separator(s string) *StringAttribute
- func (attr *StringAttribute) String() string
- func (attr *StringAttribute) Val(vals ...string) string
- type TrustElement
- type VirtualElement
Constants ¶
const ( // Parser is the tags regex parser Parser = `(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])` // AttrParser is the attribute regex parser AttrParser = `\[(.+?)(?:=("|'|)(.*?)("|'|))?\]` )
Variables ¶
var ( // SelfClosingTagToken is a list of self closing elements tag SelfClosingTagToken = []string{"area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr", "!doctype"} )
Functions ¶
Types ¶
type Attribute ¶
type Attribute interface { String() string Key(...string) string Val(...string) string Namespace(...string) string Add(...string) string Remove(...string) string }
Attribute is an attribute namespace-key-value triple.
type BaseComponent ¶
type BaseComponent struct {
// contains filtered or unexported fields
}
BaseComponent contains a controller and a view properties.
func ExtendComponent ¶
func ExtendComponent() *BaseComponent
ExtendComponent creates a basic component view
func (*BaseComponent) Controller ¶
func (component *BaseComponent) Controller()
Controller function creates map for View
func (*BaseComponent) Get ¶
func (component *BaseComponent) Get(key string) interface{}
Get returns controller value
func (*BaseComponent) Set ¶
func (component *BaseComponent) Set(key string, val interface{})
Set value to controller scope
func (*BaseComponent) View ¶
func (component *BaseComponent) View() interface{}
View function creates VirtualElement or string, int, bool
type Component ¶
type Component interface { Controller() View() interface{} Get(string) interface{} Set(string, interface{}) }
Component for Mithril
type ListAttribute ¶
type ListAttribute struct {
// contains filtered or unexported fields
}
ListAttribute is an attribute namespace-key-value triple.
func NewListAttr ¶
func NewListAttr(args ...string) *ListAttribute
NewListAttr Creates a ListAttribute object
func NewNSListAttr ¶
func NewNSListAttr(args ...string) *ListAttribute
NewNSListAttr creates a ListAttribute object
func (*ListAttribute) Add ¶
func (attr *ListAttribute) Add(vals ...string) string
Add for adding value(s) to attr store
func (*ListAttribute) Contains ¶
func (attr *ListAttribute) Contains(v string) bool
Contains return the result of if attr contains a specific value
func (*ListAttribute) Key ¶
func (attr *ListAttribute) Key(keys ...string) string
Key for sets or returns key string
func (*ListAttribute) Namespace ¶
func (attr *ListAttribute) Namespace(namespaces ...string) string
Namespace for sets and returns namespace value
func (*ListAttribute) Remove ¶
func (attr *ListAttribute) Remove(vals ...string) string
Remove for removing value(s) from attr value variable
func (*ListAttribute) Separator ¶
func (attr *ListAttribute) Separator(s string) Attribute
Separator for change specific text separator when join string array
func (*ListAttribute) String ¶
func (attr *ListAttribute) String() string
String returns ListAttribute in string format
func (*ListAttribute) Val ¶
func (attr *ListAttribute) Val(vals ...string) string
Val for sets or returns attr value
type StringAttribute ¶
type StringAttribute struct {
// contains filtered or unexported fields
}
StringAttribute is an attribute namespace-key-value triple.
func NewStringAttr ¶
func NewStringAttr(args ...string) *StringAttribute
NewStringAttr Creates a StringAttribute object
func (*StringAttribute) Add ¶
func (attr *StringAttribute) Add(vals ...string) string
Add for adding value(s) to attr store (Do nothing for StringAttribute)
func (*StringAttribute) Key ¶
func (attr *StringAttribute) Key(keys ...string) string
Key for sets or returns key string
func (*StringAttribute) Namespace ¶
func (attr *StringAttribute) Namespace(namespaces ...string) string
Namespace for sets and returns namespace value
func (*StringAttribute) Remove ¶
func (attr *StringAttribute) Remove(vals ...string) string
Remove for removing value(s) from attr value variable (Do nothing for StringAttribute)
func (*StringAttribute) Separator ¶
func (attr *StringAttribute) Separator(s string) *StringAttribute
Separator for change specific text separator when join string array (Do nothing for StringAttribute)
func (*StringAttribute) String ¶
func (attr *StringAttribute) String() string
String returns StringAttribute in string format
func (*StringAttribute) Val ¶
func (attr *StringAttribute) Val(vals ...string) string
Val for sets or returns attr value
type TrustElement ¶
type TrustElement struct {
// contains filtered or unexported fields
}
TrustElement flags a string as trusted HTML.
func Trust ¶
func Trust(str string) *TrustElement
Trust allows insert HTML for render arbitrary, potentially invalid markup, as well as run arbitrary Javascript, and therefore the developer is responsible for either
type VirtualElement ¶
VirtualElement is an object which can convert to real DOM element
func (*VirtualElement) Attr ¶
func (el *VirtualElement) Attr(key string, val ...string) string
Attr returns or sets the attribute
func (*VirtualElement) HasAttr ¶
func (el *VirtualElement) HasAttr(key string) bool
HasAttr returns true if VirtualElement has this attribute in attributes array
func (*VirtualElement) IsSelfClosingTag ¶
func (el *VirtualElement) IsSelfClosingTag() bool
IsSelfClosingTag returns true if Tag is a self closing tag element
func (*VirtualElement) String ¶
func (el *VirtualElement) String() string
String returns the html string of the element