Skip to content

Instantly share code, notes, and snippets.

@masaedw
Created May 5, 2011 02:12
Show Gist options
  • Save masaedw/956407 to your computer and use it in GitHub Desktop.
Save masaedw/956407 to your computer and use it in GitHub Desktop.
xml->hiccup
(defn xml->hiccup [xml]
(cond
(string? xml) xml
(map? xml)
(let [{:keys [tag attrs content]} xml]
(-> [tag]
(#(if (nil? attrs) % (conj % attrs)))
(#(if (empty? content) % ((comp vec concat) % (map xml->hiccup content))))))
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment