Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Compile using new node.js version of CoffeeScript

  • Loading branch information...
commit 3f348ac16b72e5d31a6ef0e097d24754c9213d3e 1 parent 0bfe5ef
Jonas Nicklas authored
8 lib/bistro_car.rb
View
@@ -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
6 lib/bistro_car/bundle.rb
View
@@ -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
2  lib/bistro_car/helpers.rb
View
@@ -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[
Please sign in to comment.
Something went wrong with that request. Please try again.