Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CoffeeScript template handler for Rails 3.
# lib/action_view/template/handlers/coffee_script.rb
module ActionView
class Template
module Handlers
class CoffeeScript
def call template
::CoffeeScript.compile(template.source).inspect
end
end
end
end
end
gem 'coffee-script'
gem 'rails_assets', :git => 'git://github.com/wycats/rails_assets.git'
# config/initializers/template_handlers.rb
require 'action_view/template/handlers/coffee_script'
ActionView::Template.register_template_handler :coffee,
ActionView::Template::Handlers::CoffeeScript.new
@apavlyut

This comment has been minimized.

Copy link

@apavlyut apavlyut commented Jan 25, 2012

Replace this:

    ::CoffeeScript.compile(source).inspect

with this:

    ::CoffeeScript.compile(template.source).inspect
@stephencelis

This comment has been minimized.

Copy link
Owner Author

@stephencelis stephencelis commented Jan 25, 2012

Typos are fun. Fixed, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment