Skip to content

Instantly share code, notes, and snippets.

@sj26
Created December 1, 2011 15:38
Show Gist options
  • Save sj26/1417639 to your computer and use it in GitHub Desktop.
Save sj26/1417639 to your computer and use it in GitHub Desktop.
# Adds SASS rendering support to Rails actionview (from controllers)
module Sass::Rails::Views
class Railtie < ::Rails::Railtie
initializer "sass-rails-views" do
# Tell ActionView we can handle SASS templates
ActionView::Template.register_template_handler :sass, Sass::Rails::Views::Template
end
# Create a SASS file as a rails template
class Template
class_attribute :default_format
self.default_format = Mime::CSS
def self.call template
"Sass::Rails::SassTemplate.new { #{template.inspect} }.render Rails.application.assets.context_class.new(Rails.application.assets, '', Rails.application.assets.root)"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment