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
Post a Comment