Module | Sass::Plugin |
In: |
lib/sass/plugin/rack.rb
lib/sass/plugin.rb |
This module handles the compilation of Sass files. It provides global options and checks whether CSS files need to be updated.
This module is used as the primary interface with Sass when it‘s used as a plugin for various frameworks. All Rack-enabled frameworks are supported out of the box. The plugin is {file:SASS_REFERENCE.md#rails_merb_plugin automatically activated for Rails and Merb}. Other frameworks must enable it explicitly; see {Sass::Plugin::Rack}.
Same as \{update_stylesheets}, but respects \{checked_for_updates} and the {file:SASS_REFERENCE.md#always_update-option `:always_update`} and {file:SASS_REFERENCE.md#always_check-option `:always_check`} options.
@see update_stylesheets
# File lib/sass/plugin.rb, line 60 60: def check_for_updates 61: return unless !Sass::Plugin.checked_for_updates || 62: Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check] 63: update_stylesheets 64: end
Non-destructively modifies \{options} so that default values are properly set.
@param additional_options [{Symbol => Object}] An options hash with which to merge \{options} @return [{Symbol => Object}] The modified options hash
# File lib/sass/plugin.rb, line 49 49: def engine_options(additional_options = {}) 50: opts = options.dup.merge(additional_options) 51: opts[:load_paths] = load_paths(opts) 52: opts 53: end
Updates out-of-date stylesheets.
Checks each Sass file in {file:SASS_REFERENCE.md#template_location-option `:template_location`} to see if it‘s been modified more recently than the corresponding CSS file in {file:SASS_REFERENCE.md#css_location-option `:css_location`}. If it has, it updates the CSS file.
# File lib/sass/plugin.rb, line 72 72: def update_stylesheets 73: return if options[:never_update] 74: 75: @checked_for_updates = true 76: template_locations.zip(css_locations).each do |template_location, css_location| 77: 78: Dir.glob(File.join(template_location, "**", "*.sass")).each do |file| 79: # Get the relative path to the file with no extension 80: name = file.sub(template_location.sub(/\/*$/, '/'), "")[0...-5] 81: 82: if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name, template_location, css_location)) 83: update_stylesheet(name, template_location, css_location) 84: end 85: end 86: end 87: end