Last active
April 22, 2016 14:48
-
-
Save pesterhazy/556cf22a2b24c9a2984503e00cb92bb7 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
;; Display arbitrary EDN-like values in a browser | |
;; | |
;; See https://github.com/yogthos/json-html | |
;; | |
;; in project.clj / build.boot: | |
;; [json-html "0.3.9"] | |
;; [hiccup "1.0.5"] | |
(require '[json-html.core :as jh] | |
'[hiccup.page]) | |
(defn pretty-edn-html [v fname] | |
(spit fname | |
(hiccup.page/html5 | |
[:head [:style (-> "json.human.css" clojure.java.io/resource slurp)]] | |
[:div {:style "max-width: 900px"} (jh/edn->html v)]))) | |
(defn browse | |
"Display an EDN-like value in the browser" | |
[v] | |
(let [fname (java.io.File/createTempFile "filename" ".html")] | |
(pretty-edn-html v fname) | |
(clojure.java.shell/sh "open" (.getAbsolutePath fname)) | |
nil)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment