Created
October 18, 2010 20:56
-
-
Save raek/633049 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn enlive->hiccup [node] | |
(if-not (map? node) | |
node | |
(let [{:keys [tag attrs content]} node | |
children (map enlive->hiccup content)] | |
(if (empty? attrs) | |
(vec (cons tag children)) | |
(vec (cons tag (cons attrs children))))))) | |
(defn hiccup->enlive [node] | |
(if-not (vector? node) | |
node | |
(let [[tag & children] node | |
attrs (when (map? (first children)) | |
(first children)) | |
children (if attrs | |
(rest children) | |
children)] | |
{:tag tag | |
:attrs attrs | |
:content (map hiccup->enlive children)}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment