Skip to content

Instantly share code, notes, and snippets.

@remvee
Created March 16, 2010 20:20
Show Gist options
  • Save remvee/334451 to your computer and use it in GitHub Desktop.
Save remvee/334451 to your computer and use it in GitHub Desktop.
multi method for rendering an object to html
(defmulti htmlify class)
(defmethod htmlify java.util.Map [value]
(html
[:dl
(map #(html [:dt (first %)]
[:dd (htmlify (last %))]) value)]))
(defmethod htmlify java.util.List [value]
(html
[:ul
(map #(html [:li (htmlify %)]) value)]))
(defmethod htmlify java.lang.Object [value]
(html
[:pre
(str value)]))
(defmethod htmlify nil [_]
(html
[:em "nil"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment