Skip to content

Instantly share code, notes, and snippets.

@Jannis
Created February 27, 2016 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jannis/ede3a929833798d7f2b3 to your computer and use it in GitHub Desktop.
Save Jannis/ede3a929833798d7f2b3 to your computer and use it in GitHub Desktop.
;; .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