Skip to content

Instantly share code, notes, and snippets.

@stephencelis
Created December 21, 2010 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stephencelis/750025 to your computer and use it in GitHub Desktop.
Save stephencelis/750025 to your computer and use it in GitHub Desktop.
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
Copy link

Replace this:

    ::CoffeeScript.compile(source).inspect

with this:

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

@stephencelis
Copy link
Author

Typos are fun. Fixed, thanks :)

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