Last active
June 19, 2017 04:50
-
-
Save thheller/7dbd69a7aa4afae644d45e1c941a7883 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
| (ns demo.macro-writing-macros) | |
| (def dom-elements | |
| '[h1 | |
| h2]) | |
| (defn gen-dom-macro [name] | |
| `(defmacro ~name [p# & c#] | |
| (let [kw# ~(-> name str keyword) | |
| children# (into [] c#)] | |
| `[~kw# ~p# ~children#]))) | |
| (defmacro define-element-macro [] | |
| `(do ~@(clojure.core/map gen-dom-macro dom-elements))) | |
| (define-element-macro) | |
| (prn (h1 {} "hello" "world")) | |
| (prn (h2 {} "hello" "world")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment