Permalink
Browse files

Compile using new node.js version of CoffeeScript

  • Loading branch information...
1 parent 0bfe5ef commit 3f348ac16b72e5d31a6ef0e097d24754c9213d3e @jnicklas committed Mar 23, 2010
Showing with 10 additions and 6 deletions.
  1. +8 −0 lib/bistro_car.rb
  2. +1 −5 lib/bistro_car/bundle.rb
  3. +1 −1 lib/bistro_car/helpers.rb
View
8 lib/bistro_car.rb
@@ -1,4 +1,5 @@
require 'jsmin'
+require 'tempfile'
require 'bistro_car/bundle'
require 'bistro_car/helpers'
@@ -12,6 +13,13 @@ class Engine < Rails::Engine
end
class << self
+ def compile(source)
+ file = Tempfile.new('script.coffee')
+ file.write(source)
+ file.close
+ %x(coffee -p #{file.path})
+ end
+
attr_accessor :mode, :minify
end
end
View
6 lib/bistro_car/bundle.rb
@@ -16,15 +16,11 @@ def render(mode)
end
def to_javascript
- minify(file_paths.map { |path| compile(path) }.join)
+ minify(file_paths.map { |path| BistroCar.compile(File.read(path)) }.join)
end
private
- def compile(path)
- %x(coffee -p #{path})
- end
-
def minify(javascript)
if BistroCar.minify then JSMin.minify(javascript) else javascript end
end
View
2 lib/bistro_car/helpers.rb
@@ -8,7 +8,7 @@ def coffee_script_bundle(*bundles)
def coffee_script(&block)
input = realign_indentation(capture(&block))
- output = CoffeeScript.compile(input)
+ output = BistroCar.compile(input)
content_tag(:script, <<-JAVASCRIPT, :type => 'text/javascript', :charset => 'utf-8')
//<![CDATA[

0 comments on commit 3f348ac

Please sign in to comment.