javascript - Bookmarklet and CoffeeScript -


i need write bookmarklet code using coffescript. (js):

javascript: (function () {   //.... }());  

but when i'm trying write code in coffeescript

javascript: (-> #... )() 

i got following:

({   javascript: (function() { //...   })() }); 

how avoid adding of "({ });"

you can add -b (or --bare flag) compile without top-level function wrapper.
see more @ $ coffee --help.

upd
-b of no if want rid of braces , around javascript: .. -- part of javascript object syntax.

you can write coffee code without javascript: (which in case of bookmarklet protocol name, not part of code), add later:

$ echo '(-> alert "hello!")()' > xx.coffee $ echo javascript:`coffee -bjcp xx.coffee` javascript:(function() { return alert("hello!"); })(); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -