Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Created February 4, 2012 06:46
Show Gist options
  • Save rummelonp/1735913 to your computer and use it in GitHub Desktop.
Save rummelonp/1735913 to your computer and use it in GitHub Desktop.
Padrino で app/javascripts/*.coffee をシステムの coffee コマンドではなく CoffeeScript gem を使ってコンパイル
module CoffeeInitializer
def self.registered(app)
app.use Rack::Coffee,
:root => Padrino.root('/app'),
:urls => '/javascripts',
:nowrap => true
# :root: the directory above urls. Defaults to Dir.pwd.
# :urls: the directories in which to look for coffeescripts. May specify a string or an array of strings. Defaults to /javascripts.
# :static: Whether to serve any static assets found in your urls (via Rack::File). Defaults to true; Specify false to pass through to your app.
# :cache: Sets a Cache-Control header if truthy, public if set to :public
# :ttl: The default max-age value for the Cache-Control header. Defaults to 86400.
# :nowrap: When true, disables the top-level function wrapper that CoffeeScript uses by default.
end
end
module Rack
class Coffee
def brew(coffee)
[CoffeeScript.compile(open(coffee), :bare => [email protected]('--bare'))]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment