[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

View File

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