CrossClj docs





    Jun 28, 2015

    Joel Holdbrooks
    Fresno, CA


    Index of all namespaces

    « Project + dependencies

    A generic data inspection component for use with Om.

    The README below is fetched from the published project artifact. Some relative links may be broken.


    A generic data inspection component.



    Add ankha as a dependency to your project.clj file:

    [ankha "0.1.4"]

    For the current development version use:

    Clojars Project

    Require ankha.core somewhere in your project.

    (ns example
      (:require [om.core :as om :include-macros true]
                [ankha.core :as ankha]))

    Next mount the ankha/inspector component with some data.

     {:points [{:x 1 :y 0}
    		   {:x 0 :y 1}
    		   {:x -1 :y 0}
    	       {:x 0 :y -1}]}
     {:target (js/document.getElementById "example")})

    Refresh your browser to so see something similar to the following.

    	:points -[
    					:x 1
    					:y 0
    					:x 0
    					:y 1
    					:x -1
    					:y 0
    					:x 0
    					:y -1

    The ankha/inspector is compatible with all Clojure data structures including record types, JavaScript objects and arrays, and all primitive types such as strings, numbers, and so forth.


    To see an example with more data, clone the repository for this project and from it’s root run

    $ lein build-example

    then open examples/a/index.html.

    Styling with CSS

    By default ankha only adds a minimum amount of styling to the output. You can use the stylesheet in examples/a/ankha.css for a better experience.

    Extending the Inspector

    Ankha provides inspection for all Clojure data types (including records), and JavaScript Arrays and Objects. You may want to provide special handling for your own custom data type, override Ankha’s existing implementations, or even types you don’t control. To do this simply implement Ankha’s IInspect protocol.

    (extend-protocol ankha/IInspect
      (-inspect [this]
        (dom/span #js {:className "record user"}
    	  (dom/span nil "First name: " (:first-name this))
    	  " "
    	  (dom/span nil "Last name: " (:last-name this)))))

    Your implementation must return a value capable of being rendered by React or Om.


    Right now only known to work with recent versions of Om (>= 0.5) and ClojureScript (>= 0.0-2156).