forked from ungerik/go-start
/
div.go
32 lines (28 loc) · 796 Bytes
/
div.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
package view
///////////////////////////////////////////////////////////////////////////////
// Div
// Div represents a HTML div element.
type Div struct {
ViewBaseWithId
Class string
Style string
Content View
OnClick string
}
func (self *Div) IterateChildren(callback IterateChildrenCallback) {
if self.Content != nil {
callback(self, self.Content)
}
}
func (self *Div) Render(ctx *Context) (err error) {
ctx.Response.XML.OpenTag("div")
ctx.Response.XML.AttribIfNotDefault("id", self.id)
ctx.Response.XML.AttribIfNotDefault("class", self.Class)
ctx.Response.XML.AttribIfNotDefault("style", self.Style)
ctx.Response.XML.AttribIfNotDefault("onclick", self.OnClick)
if self.Content != nil {
err = self.Content.Render(ctx)
}
ctx.Response.XML.ForceCloseTag()
return err
}