5 ms·
Is Rails 3.1 going to depend on having both a ruby interpreter and a JS interpreter (presumably node?) capable of running coffeescript installed?
by bonzoesc 16y ago
Is Rails 3.1 going to depend on having both a ruby interpreter and a JS interpreter (presumably node?) capable of running coffeescript installed?
- sabat 16y agoCoffeeScript isn't interpreted; it's not its own language. You write CoffeeScript code, which resembles simplified and cleaned-up Javascript, and then run a parser over it which converts it to standard Javascript. You'll need CoffeeScript (gem) installed in this situation, but that's just another Rails dependency. EDIT: I should point out that Rails will use CoffeeScript for client-side (browser) code, not server-side code. That remains Ruby and associated DSLs.
- bonzoesc 16y agoThe coffeescript compiler is written in coffeescript (and compiled to JS), so in order to serve a .coffee file you'll need to compile it, which requires JS. The commits add a dependency to the coffee-script[1] gem, which requires the execjs[2] gem, which requires some way of running JS. 1: https://github.com/josh/ruby-coffee-script https://github.com/josh/ruby-coffee-script 2: https://github.com/sstephenson/execjs https://github.com/sstephenson/execjs
- JonnieCache 16y agoNo. Coffeescript is not going to be run inside the rails stack. That would be controversial. All that's happening is by default the scaffolding generator scripts will spit out boilerplate coffeescript rather then boilerplate javascript. All that's needed to change back is to comment out a single, clearly marked line of code.
- sstephenson 16y agoThe coffee-script gem (https://github.com/josh/ruby-coffee-script https://github.com/josh/ruby-coffee-script) uses ExecJS (https://github.com/sstephenson/execjs https://github.com/sstephenson/execjs) to invoke the CS compiler. Rails 3.1's asset pipelining system will use these gems by way of Sprockets 2 (https://github.com/sstephenson/sprockets https://github.com/sstephenson/sprockets) to compile and serve CoffeeScript to the browser. If you're on Windows or Mac OS, ExecJS will use the JS runtime already installed on your system (Windows Script Host or Apple JavaScriptCore). You can also install a gem like therubyracer (V8 for MRI, available on Heroku) or therubyrhino (Rhino for JRuby) for faster compilation. And ExecJS can use Node.js or Spidermonkey if they're installed too.
- dreyfiz 16y agoI’ve heard a little about it, but is there any documentation anywhere about this new asset pipelining system in 3.1? You seem well-informed about it.