A call to the snippets macro will be expanded to a map literal. The calls to the snippet function inside the snippets macro will be executed at macro expansion time. This use of macros is a very clever hack to get some strings containing HTML into the compiled JS, but it's probably not a great example of macros in general.
You can see this by loading up the ClojureScript One REPL, but not typing (go) or (dev-server) to start the ClojureScript REPL. In the project dir, type: lein repl Then require the snippets ns: (require '[one.sample.snippets]) And macroexpand the snippets macro: (macroexpand '(one.sample.snippets/snippets)) You should see the map literal: {:form "<div id=\"form\" ...>" :greeting "<div id=\"greeting\" ...>"} Note that all that is in Clojure, but this map literal is what the ClojureScript compiler will see and compile to JS. Hope that helps, Aki On Thursday, April 5, 2012 4:19:22 PM UTC-4, Duraid wrote: > > In this doc ( > https://github.com/brentonashworth/one/wiki/Design-and-templating) under > 'Including templates in the application' it says: > > * In ClojureScript, macros are Clojure macros and run only at compile > time. This means we can use any Clojure library from a macro. * > * > * > The way I understand it is that in clojure macros get expanded before > evaluation. How is that different in ClojureScript? > > So in the the example from the document, the snippets macro will be > expanded and include a call to the snippet function that will be called at > runtime which in turn calls the enlive library which is a clojure library. > So how does that work? > > Thanks > On Thursday, April 5, 2012 4:19:22 PM UTC-4, Duraid wrote: > > In this doc ( > https://github.com/brentonashworth/one/wiki/Design-and-templating) under > 'Including templates in the application' it says: > > * In ClojureScript, macros are Clojure macros and run only at compile > time. This means we can use any Clojure library from a macro. * > * > * > The way I understand it is that in clojure macros get expanded before > evaluation. How is that different in ClojureScript? > > So in the the example from the document, the snippets macro will be > expanded and include a call to the snippet function that will be called at > runtime which in turn calls the enlive library which is a clojure library. > So how does that work? > > Thanks > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en