From c5e3aff7df24ecdc54b3f0207be78da8382f4f45 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Sun, 22 Sep 2019 15:10:06 +0200 Subject: [PATCH] [IMP]Hy base : allow attrs as child as 2nd arg for xmln --- hy_base/xml.hy | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hy_base/xml.hy b/hy_base/xml.hy index 211abde..98cff1b 100644 --- a/hy_base/xml.hy +++ b/hy_base/xml.hy @@ -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 [])})