Sha256: 47b1f0a1afd239a801d525634e9398967e668b7f0d1541dd10c76803e7871389

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 Bytes

Contents

module Coffee
  module Rails
    class TemplateHandler
      def self.erb_handler
        @@erb_handler ||= ActionView::Template.registered_template_handler(:erb)
      end

      def self.call(template)
        compiled_source = erb_handler.call(template)
        "CoffeeScript.compile(begin;#{compiled_source};end)"
      end
    end
  end
end

ActiveSupport.on_load(:action_view) do
  ActionView::Template.register_template_handler :coffee, Coffee::Rails::TemplateHandler
  # Loads DependencyTracker
  require 'action_view/dependency_tracker'
  # Register ERB DependencyTracker for .coffee files to enable digesting.
  ActionView::DependencyTracker.register_tracker :coffee, ActionView::DependencyTracker::ERBTracker
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coffee-rails-4.2.2 lib/coffee/rails/template_handler.rb