本文整理汇总了Golang中github.com/kpmy/ot/otm.Object.ChildrenObjects方法的典型用法代码示例。如果您正苦于以下问题:Golang Object.ChildrenObjects方法的具体用法?Golang Object.ChildrenObjects怎么用?Golang Object.ChildrenObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/kpmy/ot/otm.Object
的用法示例。
在下文中一共展示了Object.ChildrenObjects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: renderHtml
func renderHtml(o otm.Object, log *testing.T) {
buf := bytes.NewBufferString("<!DOCTYPE HTML>")
e := xml.NewEncoder(buf)
var obj func(otm.Object)
obj = func(o otm.Object) {
clazz := o.InstanceOf().Qualident()
if clazz.Template == "html" {
start := xml.StartElement{}
start.Name.Local = clazz.Class
if id := o.Qualident().Identifier; id != "" {
attr := xml.Attr{}
attr.Name.Local = "id"
attr.Value = id
start.Attr = append(start.Attr, attr)
}
e.EncodeToken(start)
for _x := range o.Children() {
switch x := _x.(type) {
case otm.Object:
obj(x)
case string:
e.EncodeToken(xml.CharData([]byte(x)))
default:
halt.As(100, reflect.TypeOf(x))
}
}
e.EncodeToken(start.End())
}
}
for x := range o.ChildrenObjects() {
if x.InstanceOf().Qualident().Template == "html" && x.InstanceOf().Qualident().Class == "html" {
obj(x)
}
}
e.Flush()
log.Log(buf.String())
}
示例2: resolve
func resolve(t *ForeignTemplate, o otm.Object) (err error) {
assert.For(!fn.IsNil(o), 20)
var processList []pfunc
var upd func(t *ForeignTemplate, o otm.Object)
upd = func(t *ForeignTemplate, o otm.Object) {
if clazz, ok := t.Classes[o.Qualident().Class]; ok && (o.Qualident().Template == t.TemplateName || o.Qualident().Template == "") {
inst := clazz.copyOf()
o.InstanceOf(inst)
if fn := inst.apply(o); fn != nil {
processList = append(processList, fn)
}
//log.Println("class updated for", o.Qualident(), " set ", clazz.Qualident())
}
for x := range o.ChildrenObjects() {
upd(t, x)
}
}
upd(t, o)
for tmp := processList; len(tmp) > 0; {
var _tmp []pfunc
for _, f := range tmp {
var p pfunc
if p, err = f(); err == nil && p != nil {
_tmp = append(_tmp, p)
} else if err != nil {
_tmp = nil
break
}
}
tmp = _tmp
}
return
}
示例3: forEach
func (w *Walker) forEach(o otm.Object, do func(w *Walker, o otm.Object)) {
for v := range o.ChildrenObjects() {
do(w, v)
}
}