[IMP]Hy base : allow attrs as child as 2nd arg for xmln

This commit is contained in:
Fabien BOURGEOIS 2019-09-22 15:10:06 +02:00
parent 82fd49a5e5
commit c5e3aff7df
1 changed files with 7 additions and 5 deletions

View File

@ -38,8 +38,10 @@
(setv subchildren (get child "children")) (setv subchildren (get child "children"))
(if subchildren (xmlchild new_parent subchildren)))))) (if subchildren (xmlchild new_parent subchildren))))))
(defn xmln [tag &optional attrs children text] (defn xmln [tag &optional attrs children]
"XMLNode with default children, not attributes" "XMLNode with optional attributes or children, defaults according to second
(setv children (or (if text [text] children) [])) argument type or empty dict and list"
{"tag" tag "attrs" (or attrs {}) "children" children} (if (and attrs (not children))
) (if (instance? list attrs)
(do (setv children attrs) (setv attrs {}))))
{"tag" tag "attrs" (or attrs {}) "children" (or children [])})