I tried the following:

1. Created a project with David Nolen's lein template (taken from 
here<http://swannodette.github.io/2013/10/27/the-essence-of-clojurescript/>
):
 

*$ lein new mies hello-world* 


2. Created a *macro.clj* file in the *src/hello-world*  folder with the 
contents you posted:

*$ touch src/hello_world/macro.clj*


3. Edited the *src/hello_world/core.clj *file so that it requires the macro 
and uses it:

*(ns hello-world.core*
*  (:require-macros [hello-world.macro :as macro])) *

*(macro/my-when true*
*  (. js/console (log "Hello world!")))*


4. Started cljsbuild auto and wait for it to finish compilation:
 

*$ lein cljsbuild auto hello-world*


5. Opened the *index.html* file in a browser and verified the console 
message was there.

It worked this way in my case. This is the *project.clj* for this project, 
maybe the *:cljsbuild* configuration in yours has the *:source-paths*messed up?

*(defproject hello-world "0.1.0-SNAPSHOT"*
*  :description "FIXME: write this!"*
*  :url "http://example.com/FIXME"*

*  :dependencies [[org.clojure/clojure "1.5.1"]*
*                 [org.clojure/clojurescript "0.0-2030"]]*

*  :plugins [[lein-cljsbuild "1.0.0-alpha2"]]*

*  :source-paths ["src"]*

*  :cljsbuild { *
*    :builds [{:id "hello-world"*
*              :source-paths ["src"]*
*              :compiler {*
*                :output-to "hello_world.js"*
*                :output-dir "out"*
*                :optimizations :none*
*                :source-map true}}]})*

HTH,

Juan

On Thursday, November 21, 2013 11:51:22 AM UTC+8, Ed Yu wrote:
>
> Hello,
>   I'm stuck on this particular problem that I'm having problem figuring 
> out what to do:
>
> Say I have a leiningen project that has a simple ClojureScript 
> src/cljs/hello_world/hello.cljs file that has the following:
>
> (ns hello-world.hello
>   (:require-macros [hello-world.macro :as macro]))
>
> (defn ^:export main []
>   (macro/my-when true
>     (.write js/document "Hello, world!")))
>
> and I have the macro file macro.clj
>
> (ns hello-world.macro)
>
> (defmacro my-when [condition & body]
>   `(if ~condition (do ~@body)))
>
> I can't figure out where do I put macro.clj for cljsc or 
> cljs.closure/build to find the macro. I tried placing the macro.clj in the 
> same directory as hello.cljs or place it under src/clj/hello_world or place 
> it directory under src/hello_world. It doesn't matter where I put it, it 
> will not compile as I get the following error:
>
> FileNotFoundException Could not locate hello_world/macro__init.class or 
> hello_world/macro.clj on classpath:   clojure.lang.RT.load (RT.java:443)
>
> Thank you
>
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to