/
tag.go
53 lines (48 loc) · 1.13 KB
/
tag.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package view
///////////////////////////////////////////////////////////////////////////////
// Tag
// Tag represents an arbitrary HTML element.
type Tag struct {
ViewBaseWithId
Tag string
Content View
Class string
Attribs map[string]string
ExtraClose bool
}
func (self *Tag) IterateChildren(callback IterateChildrenCallback) {
if self.Content != nil {
callback(self, self.Content)
}
}
func (self *Tag) Render(ctx *Context) (err error) {
ctx.Response.XML.OpenTag(self.Tag)
ctx.Response.XML.AttribIfNotDefault("id", self.id)
ctx.Response.XML.AttribIfNotDefault("class", self.Class)
for key, value := range self.Attribs {
ctx.Response.XML.Attrib(key, value)
}
if self.Content != nil {
err = self.Content.Render(ctx)
}
if self.ExtraClose {
ctx.Response.XML.CloseTagAlways()
} else {
ctx.Response.XML.CloseTag()
}
return err
}
//func (self *Tag) SetClass(class string) {
// self.Class = class
// ViewChanged(self)
//}
//
//func (self *Tag) SetContent(content View) {
// self.Content = content
// ViewChanged(self)
//}
//
//func (self *Tag) SetTag(tag string) {
// self.Tag = tag
// ViewChanged(self)
//}