Skip to content

eriksvedang/data-to-html

Repository files navigation

data-to-html

A Clojure library for converting data structures into html and opening them in a browser for inspection. It's very similar to clojure.inspector/inspect-tree but more readable to my eyes.

API documentation

Installation

Clojars Project

[data-to-html "0.1.3-SNAPSHOT"]

Usage

Import the project and its two functions

(ns weather.core
  (require [data-to-html.core :refer [convert open-in-browser inspect]]))

Define some data

(def my-data {:temperature 27 :forecast #{:cloudy :rain :thunder}})

Run the data through convert to turn it into a html string. Use open-in-browser to save the string into a html page and make your OS open it in a browser.

(-> my-data
    convert
    open-in-browser)

You can also use inspect to do it all in one function call

(inspect my-data)

inspect also returns the data again so that you can insert it in the middle of a threading macro

(-> my-data
    :forecast
    inspect ; opens browser!
    :cloudy
    boolean) ; => true

Todo

  • Use tree walk instead
  • Add foldable nodes to the tree (jquery)
  • Make sure lazy seqs and symbols work properly

License

Copyright © 2013 Erik Svedäng

Distributed under the Eclipse Public License, the same as Clojure.

About

Convert clojure data to html

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published