Skip to content

Commit

Permalink
Only set those compass configuration options that have been explicitl…
Browse files Browse the repository at this point in the history
…y set by the user.

Closes GH-21.
  • Loading branch information
chriseppstein committed Mar 11, 2012
1 parent 6201548 commit 40cc1b8
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions lib/compass-rails.rb
Expand Up @@ -177,8 +177,18 @@ def initialize!(config = nil)

def configure_rails!(app)
return unless app.config.respond_to?(:sass)
app.config.compass.to_sass_engine_options.each do |key, value|
app.config.sass.send(:"#{key}=", value)
sass_config = app.config.sass
compass_config = app.config.compass

sass_config.load_paths.concat(compass_config.sass_load_paths)

{ :output_style => :style,
:line_comments => :line_comments,
:cache => :cache,
:disable_warnings => :quiet,
:preferred_syntax => :preferred_syntax
}.each do |compass_option, sass_option|
set_maybe sass_config, compass_config, sass_option, compass_option
end
end

Expand All @@ -198,6 +208,16 @@ def asset_pipeline_enabled?
rails_config.respond_to?(:assets) && rails_config.assets.try(:enabled)
end

private

# sets the sass config value only if the corresponding compass-based setting
# has been explicitly set by the user.
def set_maybe(sass_config, compass_config, sass_option, compass_option)
if compass_value = compass_config.send(:"#{compass_option}_without_default")
sass_config.send(:"#{sass_option}=", compass_value)
end
end

end

Compass::AppIntegration.register(:rails, "::CompassRails")
Expand Down

0 comments on commit 40cc1b8

Please sign in to comment.