Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ncri
Created September 23, 2012 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncri/3772514 to your computer and use it in GitHub Desktop.
Save ncri/3772514 to your computer and use it in GitHub Desktop.
module Coffee
module Rails
class HamlTemplateHandler
def self.haml_handler
@@haml_handler ||= ActionView::Template.registered_template_handler(:haml)
end
def self.call(template)
compiled_source = haml_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_haml, Coffee::Rails::HamlTemplateHandler
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment