Skip to content

Instantly share code, notes, and snippets.

@cemerick
Created December 15, 2011 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemerick/2a64e0067c960ea86354 to your computer and use it in GitHub Desktop.
Save cemerick/2a64e0067c960ea86354 to your computer and use it in GitHub Desktop.
hiccup -> clojure.xml
; problems:
; * doesn't elide empty attrs e.g. id="" class=""
; * doesn't convert e.g. {:selected true} into selected=selected
(defn- hiccup->corexml
[x]
(if (coll? x)
(let [[tag attrs content] (#'hiccup.core/normalize-element x)]
{:tag (keyword tag) :attrs attrs :content (map hiccup->corexml content)})
(str x)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment