lib/sass/rails/railtie.rb in sass-rails-3.1.0.rc.5 vs lib/sass/rails/railtie.rb in sass-rails-3.1.0.rc.6
- old
+ new
@@ -1,7 +1,12 @@
+require 'sprockets/railtie'
+
module Sass::Rails
class Railtie < ::Rails::Railtie
+ module SassContext
+ attr_accessor :sass_config
+ end
config.sass = ActiveSupport::OrderedOptions.new
# Establish static configuration defaults
# Emit scss files during stylesheet generation of scaffold
config.sass.preferred_syntax = :scss
# Use expanded output instead of the sass default of :nested
@@ -15,10 +20,16 @@
# Initialize the load paths to an empty array
config.sass.load_paths = []
# Send Sass logs to Rails.logger
config.sass.logger = Sass::Rails::Logger.new
+ config.before_initialize do
+ require 'sprockets/engines'
+ Sprockets.register_engine '.sass', Sass::Rails::SassTemplate
+ Sprockets.register_engine '.scss', Sass::Rails::ScssTemplate
+ end
+
initializer :setup_sass do |app|
# Only emit one kind of syntax because though we have registered two kinds of generators
syntax = app.config.sass.preferred_syntax.to_sym
alt_syntax = syntax == :sass ? "scss" : "sass"
app.config.generators.hide_namespace alt_syntax
@@ -32,9 +43,11 @@
# Establish configuration defaults that are evironmental in nature
if config.sass.full_exception.nil?
# Display a stack trace in the css output when in development-like environments.
config.sass.full_exception = app.config.consider_all_requests_local
end
+ app.assets.context_class.extend(SassContext)
+ app.assets.context_class.sass_config = app.config.sass
end
initializer :setup_compression do |app|
if app.config.assets.compress
# Use sass's css_compressor