Module: Sass::Plugin
- Defined in:
- lib/gems/haml-2.0.4/lib/sass/plugin.rb
Overview
This module contains methods to aid in using Sass as a stylesheet-rendering plugin for various systems. Currently Rails/ActionController and Merb are supported out of the box.
Constant Summary collapse
- @@options =
{ :template_location => './public/stylesheets/sass', :css_location => './public/stylesheets', :always_update => false, :always_check => true, :full_exception => true }
- @@checked_for_updates =
false
Class Method Summary collapse
-
.checked_for_updates ⇒ Object
Whether or not Sass has ever checked if the stylesheets need updates (in this Ruby instance).
-
.engine_options(additional_options = {}) ⇒ Object
Get the options ready to be passed to the Sass::Engine.
-
.options ⇒ Object
Gets various options for Sass.
-
.options=(value) ⇒ Object
Sets various options for Sass.
-
.update_stylesheets ⇒ Object
Checks each stylesheet in
options[:css_location]
to see if it needs updating, and updates it using the corresponding template fromoptions[:templates]
if it does.
Class Method Details
.checked_for_updates ⇒ Object
Whether or not Sass has ever checked if the stylesheets need updates (in this Ruby instance).
20 21 22 |
# File 'lib/gems/haml-2.0.4/lib/sass/plugin.rb', line 20 def checked_for_updates @@checked_for_updates end |
.engine_options(additional_options = {}) ⇒ Object
Get the options ready to be passed to the Sass::Engine
38 39 40 41 42 |
# File 'lib/gems/haml-2.0.4/lib/sass/plugin.rb', line 38 def ( = {}) opts = .dup.merge() opts[:load_paths] = load_paths(opts) opts end |
.options ⇒ Object
Gets various options for Sass. See README.rdoc for details. – TODO: *DOCUMENT OPTIONS* ++
28 29 30 |
# File 'lib/gems/haml-2.0.4/lib/sass/plugin.rb', line 28 def @@options end |
.options=(value) ⇒ Object
Sets various options for Sass.
33 34 35 |
# File 'lib/gems/haml-2.0.4/lib/sass/plugin.rb', line 33 def (value) @@options.merge!(value) end |
.update_stylesheets ⇒ Object
Checks each stylesheet in options[:css_location]
to see if it needs updating, and updates it using the corresponding template from options[:templates]
if it does.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/gems/haml-2.0.4/lib/sass/plugin.rb', line 49 def update_stylesheets return if [:never_update] @@checked_for_updates = true Dir.glob(File.join([:template_location], "**", "*.sass")).entries.each do |file| # Get the relative path to the file with no extension name = file.sub([:template_location] + "/", "")[0...-5] if !forbid_update?(name) && ([:always_update] || stylesheet_needs_update?(name)) css = css_filename(name) File.delete(css) if File.exists?(css) filename = template_filename(name) engine = Engine.new(File.read(filename), (:filename => filename)) result = begin engine.render rescue Exception => e exception_string(e) end # Create any directories that might be necessary dirs = [[:css_location]] name.split("/")[0...-1].each { |dir| dirs << "#{dirs[-1]}/#{dir}" } dirs.each { |dir| Dir.mkdir(dir) unless File.exist?(dir) } # Finally, write the file File.open(css, 'w') do |file| file.print(result) end end end end |