Class: SC::Builder::Sass
Overview
This build can compile a Sass stylesheet. At this point it does no further processing than simply executing the Sass. It would be nice to add support for sc_static and other directives at some point.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
build, #initialize, #joinlines, #readlines, #replace_static_url, #static_url, #writelines
Constructor Details
This class inherits a constructor from SC::Builder::Base
Instance Method Details
#build(dst_path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/sproutcore/builders/sass.rb', line 19 def build(dst_path) begin require 'sass' rescue raise "Cannot compile #{entry.source_path} because sass is not installed. Please try 'sudo gem install haml' and try again" end begin content = readlines(entry.source_path)*'' content = ::Sass::Engine.new(content).render writelines dst_path, [content] rescue Exception => e # explain sass syntax error a bit more... if e.is_a? Sass::SyntaxError e_string = "#{e.class}: #{e.}" e_string << "\non line #{e.sass_line}" e_string << " of #{@entry.source_path}" if File.exists?(@entry.source_path) e_string << "\n\n" min = [e.sass_line - 5, 0].max File.read(@entry.source_path).rstrip.split("\n")[ min .. e.sass_line + 5 ].each_with_index do |line, i| e_string << "#{min + i + 1}: #{line}\n" end # File.read end # if File.exists? raise e_string else raise e # reraise end end # rescue end |