Created
February 27, 2016 00:50
-
-
Save Jannis/ede3a929833798d7f2b3 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
;; .clj | |
(defn defcomponents* | |
[components] | |
`(let [components# (~'js->clj ~components) | |
defcomponent# (fn [[n# c#]] | |
`(defn ~(symbol (str n# "-component")) [] | |
"foo"))] | |
`(do | |
~@(map defcomponent# components#)))) | |
(defmacro defcomponents | |
[components] | |
(defcomponents* components)) | |
;; cljs | |
(println (defcomponents js/SomeJSObject)) | |
;; prints this in the JS console: | |
(do (clojure.core/defn Button-component [] foo) (clojure.core/defn Card-component [] foo) (clojure.core/defn Heading-component [] foo) (clojure.core/defn Layout-component [] foo) (clojure.core/defn Text-component [] foo)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment