Created
July 14, 2016 10:39
-
-
Save danielytics/175b4c2b23483f0849f08dfd6445357c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(def rui-components | |
{'list rui/list | |
'list-item rui/list-item}) | |
(def component-registry | |
(merge | |
rui-components | |
{})) | |
(def my-template | |
[:div | |
[:div "Hello"] | |
['list {} | |
['list-item {:primaryText "Test 1"}] | |
['list-item {:primaryText "Test 2"}]]]) | |
(defnav hiccup-node-view [pred?] | |
(select* [this structure next-fn] | |
(let [walker (fn this [structure] | |
(if (vector? structure) | |
(if (pred? structure) | |
(into [(next-fn structure)] (map this structure)) | |
(mapv this structure)) | |
sp/STOP))] | |
(walker structure))) | |
(transform* [this structure next-fn] | |
(let [walker (fn this [structure] | |
(if (vector? structure) | |
(if (pred? structure) | |
(next-fn (mapv this structure)) | |
(mapv this structure)) | |
structure))] | |
(walker structure)))) | |
(defn gen [] | |
(transform | |
[(hiccup-node-view (comp symbol? first))] | |
(fn [node] | |
(match [node] | |
[[elem (attrs :guard map?) & children]] | |
((get component-registry elem) attrs (apply list children)) | |
[[elem & children]] | |
((get component-registry elem) {} (apply list children)))) | |
my-template)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment