unless defined?(Sass::RAILS_LOADED) Sass::RAILS_LOADED = true module Sass::Plugin::Configuration # Different default options in a rails envirionment. def default_options @default_options ||= { :always_update => false, :template_location => Sass::Util.rails_root + '/public/stylesheets/sass', :css_location => Sass::Util.rails_root + '/public/stylesheets', :cache_location => Sass::Util.rails_root + '/tmp/sass-cache', :always_check => Sass::Util.rails_env == "development", :quiet => Sass::Util.rails_env != "production", :full_exception => Sass::Util.rails_env != "production" }.freeze end end Sass::Plugin.options.reverse_merge!(Sass::Plugin.default_options) if Sass::Util.ap_geq?('3.1.0.beta') require 'sass/importers/rails' class Sass::Plugin::TemplateHandler attr_reader :syntax def initialize(syntax) @syntax = syntax end def handles_encoding?; true; end def call(template, view) rails_importer = Sass::Importers::Rails.new(view.lookup_context) tree = Sass::Engine.new(template.source, :syntax => @syntax, :cache => false, :filename => template.virtual_path, :importer => rails_importer, :load_paths => [rails_importer], ).to_tree < [importer], :cache => false)) if staleness_checker.stylesheet_modified_since?( #{template.virtual_path.inspect}, #{Time.now.to_i}, importer) @_template.expire! @_template.rerender(self) else #{tree.render.inspect} end RUBY end end ActionView::Template.register_template_handler(:sass, Sass::Plugin::TemplateHandler.new(:sass)) ActionView::Template.register_template_handler(:scss, Sass::Plugin::TemplateHandler.new(:scss)) elsif defined?(ActionController::Metal) # Rails >= 3.0 require 'sass/plugin/rack' Rails.configuration.middleware.use(Sass::Plugin::Rack) elsif defined?(ActionController::Dispatcher) && defined?(ActionController::Dispatcher.middleware) # Rails >= 2.3 require 'sass/plugin/rack' ActionController::Dispatcher.middleware.use(Sass::Plugin::Rack) else module ActionController class Base alias_method :sass_old_process, :process def process(*args) Sass::Plugin.check_for_updates sass_old_process(*args) end end end end end