Module: Sass::Plugin
- Extends:
- Plugin
- Defined in:
- /var/www/haml-pages/.haml/lib/sass/plugin.rb,
/var/www/haml-pages/.haml/lib/sass/plugin/rack.rb
Overview
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 automatically activated for Rails and Merb. Other frameworks must enable it explicitly; see Sass::Plugin::Rack.
Defined Under Namespace
Classes: Rack
Instance Attribute Summary
- - (Boolean) checked_for_updates readonly Whether or not Sass has ever checked if the stylesheets need to be updated (in this Ruby instance).
- - ({Symbol => Object}) options An options hash.
Instance Method Summary
-
- check_for_updates
Same as #update_stylesheets, but respects #checked_for_updates and the
:always_updateand:always_checkoptions. - - ({Symbol => Object}) engine_options(additional_options = {}) Non-destructively modifies #options so that default values are properly set.
- - update_stylesheets Updates out-of-date stylesheets.
Instance Attribute Details
- (Boolean) checked_for_updates (readonly)
Whether or not Sass has ever checked if the stylesheets need to be updated (in this Ruby instance).
29 30 31 |
# File '/var/www/haml-pages/.haml/lib/sass/plugin.rb', line 29
def checked_for_updates
@checked_for_updates
end
|
- ({Symbol => Object}) options
An options hash. See the Sass options documentation.
35 36 37 |
# File '/var/www/haml-pages/.haml/lib/sass/plugin.rb', line 35
def options
@options
end
|
Instance Method Details
- check_for_updates
Same as #update_stylesheets, but respects #checked_for_updates and the :always_update and :always_check options.
60 61 62 63 64 |
# File '/var/www/haml-pages/.haml/lib/sass/plugin.rb', line 60
def check_for_updates
return unless !Sass::Plugin.checked_for_updates ||
Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
update_stylesheets
end
|
- ({Symbol => Object}) engine_options(additional_options = {})
Non-destructively modifies #options so that default values are properly set.
49 50 51 52 53 |
# File '/var/www/haml-pages/.haml/lib/sass/plugin.rb', line 49
def engine_options(additional_options = {})
opts = options.dup.merge(additional_options)
opts[:load_paths] = load_paths(opts)
opts
end
|
- update_stylesheets
Updates out-of-date stylesheets.
Checks each Sass file in :template_location to see if it’s been modified more recently than the corresponding CSS file in :css_location. If it has, it updates the CSS file.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File '/var/www/haml-pages/.haml/lib/sass/plugin.rb', line 72
def update_stylesheets
return if options[:never_update]
@checked_for_updates = true
template_locations.zip(css_locations).each do |template_location, css_location|
Dir.glob(File.join(template_location, "**", "*.sass")).each do |file|
# Get the relative path to the file with no extension
name = file.sub(template_location.sub(/\/*$/, '/'), "")[0...-5]
if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name, template_location, css_location))
update_stylesheet(name, template_location, css_location)
end
end
end
end
|