| Module | Sass::Plugin |
| In: |
lib/sass/plugin.rb
|
Get the options ready to be passed to the Sass::Engine
# 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
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.
# 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