github.com/vugu/vugu@v0.3.5/attribute-lister.go (about) 1 package vugu 2 3 // VGAttributeLister implements the required functionality, required by the `:=` attribute setter. 4 // Types may implement this interface, to 5 type VGAttributeLister interface { 6 AttributeList() []VGAttribute 7 } 8 9 // The VGAttributeListerFunc type is an adapter to allow the use of functions as VGAttributeLister 10 type VGAttributeListerFunc func() []VGAttribute 11 12 // AttributeList calls the underlying function 13 func (f VGAttributeListerFunc) AttributeList() []VGAttribute { 14 return f() 15 } 16 17 // AttrMap implements VGAttributeLister as a map[string]interface{} 18 type AttrMap map[string]interface{} 19 20 // AttributeList returns an attribute list corresponding to this map using the rules from VGNode.AddAttrInterface. 21 func (m AttrMap) AttributeList() (ret []VGAttribute) { 22 var n VGNode 23 for k := range m { 24 n.AddAttrInterface(k, m[k]) 25 } 26 return n.Attr 27 }