Пример #1
0
func rebuildTree(node models.TreeLink, newTree models.PTreeNode) {
	switch node.Type {
	case models.TREE_NODE:
		treeRebuilding(node.AsNode(), newTree)
	case models.TREE_VALUE:
		(*newTree).AddChild(node)
	default:
		fmt.Println("[rebuildTree] UNEXCEPTION TreeElementType! ID ", node.ID)
	}
}
Пример #2
0
func makeList(tree models.PTreeNode, isFirst bool) (result string) {
	var e *models.TreeLink
	for _, e = range tree.ChildList {
		var resLi string
		if e.Type == models.TREE_VALUE {
			resLi = EscapedLink((*(e.AsValue().Value.Value)).String())
		} else {
			node := e.AsNode()
			resLi = string(node.Type()) + " " + strings.TrimSpace(node.Value)
			if len(strings.TrimSpace(resLi)) == 0 {
				resLi = "EMPTY"
			}
			resLi = EscapedLink(resLi)
			resLi += makeList(node, false)
		}
		result += TAG_ELEM.Wrap(resLi)
	}
	if isFirst {
		result = TAG_LIST.AddAttr(ATTR_CLASS, "tree").Wrap(result)
	} else {
		result = TAG_LIST.Wrap(result)
	}
	return
}