Module Sass::Plugin
In: lib/sass/plugin.rb

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.

Methods

Public Class methods

Whether or not Sass has ever checked if the stylesheets need updates (in this Ruby instance).

[Source]

    # File lib/sass/plugin.rb, line 20
20:       def checked_for_updates
21:         @@checked_for_updates
22:       end

Get the options ready to be passed to the Sass::Engine

[Source]

    # File lib/sass/plugin.rb, line 38
38:       def engine_options(additional_options = {})
39:         opts = options.dup.merge(additional_options)
40:         opts[:load_paths] = load_paths(opts)
41:         opts
42:       end

Gets various options for Sass. See README.rdoc for details.

[Source]

    # File lib/sass/plugin.rb, line 28
28:       def options
29:         @@options
30:       end

Sets various options for Sass.

[Source]

    # File lib/sass/plugin.rb, line 33
33:       def options=(value)
34:         @@options.merge!(value)
35:       end

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.

[Source]

    # File lib/sass/plugin.rb, line 49
49:       def update_stylesheets
50:         return if options[:never_update]
51: 
52:         @@checked_for_updates = true
53:         Dir.glob(File.join(options[:template_location], "**", "*.sass")).entries.each do |file|
54: 
55:           # Get the relative path to the file with no extension
56:           name = file.sub(options[:template_location] + "/", "")[0...-5]
57: 
58:           if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name))
59:             css = css_filename(name)
60:             File.delete(css) if File.exists?(css)
61: 
62:             filename = template_filename(name)
63:             engine = Engine.new(File.read(filename), engine_options(:filename => filename))
64:             result = begin
65:                        engine.render
66:                      rescue Exception => e
67:                        exception_string(e)
68:                      end
69: 
70:             # Create any directories that might be necessary
71:             dirs = [options[:css_location]]
72:             name.split("/")[0...-1].each { |dir| dirs << "#{dirs[-1]}/#{dir}" }
73:             dirs.each { |dir| Dir.mkdir(dir) unless File.exist?(dir) }
74: 
75:             # Finally, write the file
76:             File.open(css, 'w') do |file|
77:               file.print(result)
78:             end
79:           end
80:         end
81:       end

[Validate]