Hello,
So just to get it out: I do not want to evaluate the JavaScript, simply 
preserve it.

I'm working on an ArangoDB driver. Part of the wonder that is ArangoDB is 
its ability to support transactions. This is done using JSON. Part of the 
REST object for a transaction is what I want to do in the transaction. This 
is encapsulated in the "action" attribute of the posted JSON object. 

Here's an example
{...JSON configuration....
 action: "function (){many lines of stuff here",
 ....More JSON configuration}

Now the way that this works in node is by converting the function into a 
String. I didn't know that String(function () {..valid JavaScript...}) 
would kick out a string version of the function. Pretty neat.

I want to do the same thing with Clojure. I presently take a map with one 
of the attributes of :action. I want something like this.
{:some-key :some-value,
 :action  (js-macro function(){
                      console.log("pretty crappy transaction");
                      console.log("another line");
                    })}

On the other side of the macro I want to get "function() {\t\t\t\n 
console.log(\"pretty crappy transaction\";\n\t\t\tconsole.log(\"another 
line\");\n} or there about.

I've got

(defmacro js [& js-fun]

    (let [body (str js-fun)]

    (subs body 1 (- (count body) 1))))

That gets the idea. Unfortunately, I loose the ";" as well as the new lines.

I'm pretty sure I don't *need* this macro. I can probably get away with 
"function () {
  console.log('println');
}", but I feel like this would make the code nicer.

Thanks,
JPD

-- 
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/d/optout.

Reply via email to