Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (38 sloc) 1.05 KB
(ns example.reagent
(:require [clojure.pprint]
[reagent.core :as r]))
[:th "name"]] [:th "country"] [:th "date"]]
[:td "Descartes"] [:td "France"] [:td "1596"]]
;; ...
(defn row-ui [cols m]
[:tr {:key (:name m)} (map (fn [col] [:td {:key col} (get m col)]) cols)])
(defn table-ui [cols rel]
[:tr (map (fn [col] [:th {:key col} (name col)]) cols)]]
(map (partial row-ui cols) rel)]])
(def philosopher-cols
[:name :country :date])
(def philosophers
[{:name "Descartes" :country "France" :date 1596}
{:name "Kant" :country "Prussia" :date 1724}
{:name "Quine" :country "U.S.A." :date 1908}])
(defn root []
[:h1 "philosophers"]
[table-ui philosopher-cols philosophers]])
(defn gadget2 []
(clojure.pprint/print-table philosopher-cols philosophers))
(defn gadget []
(clojure.pprint/pprint (table-ui philosopher-cols
You can’t perform that action at this time.