Class: Jekyll::Sass::SassCssFile
- Inherits:
-
StaticFile
- Object
- StaticFile
- Jekyll::Sass::SassCssFile
- Defined in:
- lib/jekyll-sass.rb
Class Attribute Summary collapse
-
.should_write_sass ⇒ Object
Returns the value of attribute should_write_sass.
Instance Method Summary collapse
-
#destination(dest) ⇒ Object
Obtain destination path.
- #in_place_destination(dest) ⇒ Object
-
#write(dest) ⇒ Object
Convert the sass/scss file into a css file.
Class Attribute Details
.should_write_sass ⇒ Object
Returns the value of attribute should_write_sass.
40 41 42 |
# File 'lib/jekyll-sass.rb', line 40 def should_write_sass @should_write_sass end |
Instance Method Details
#destination(dest) ⇒ Object
Obtain destination path.
+dest+ is the String path to the destination dir
Returns destination file path.
47 48 49 |
# File 'lib/jekyll-sass.rb', line 47 def destination(dest) File.join(dest, @dir, File.basename(@name, ".*") + ".css") end |
#in_place_destination(dest) ⇒ Object
51 52 53 |
# File 'lib/jekyll-sass.rb', line 51 def in_place_destination(dest) File.join(File.dirname(path), File.basename(@name, ".*") + ".css") end |
#write(dest) ⇒ Object
Convert the sass/scss file into a css file.
+dest+ is the String path to the destination dir
Returns false if the file was not modified since last time (no-op).
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/jekyll-sass.rb', line 59 def write(dest) return false if !SassCssFile.should_write_sass @@mtimes[path] = mtime dest_path = destination(dest) FileUtils.mkdir_p(File.dirname(dest_path)) begin engine = ::Sass::Engine.for_file(path, :style => SassConfig.style(@site), :line_comments => SassConfig.line_comments(@site)) content = engine.render File.open(dest_path, 'w') do |f| f.write(content) end if SassConfig.compile_in_place?(@site) in_place_dest_path = in_place_destination(dest) File.open(in_place_dest_path, 'w') do |f| f.write(content) end end rescue ::Sass::SyntaxError => e STDERR.puts "Sass failed generating '#{e.sass_filename}' line:#{e.sass_line} '#{e.}'".red false end true end |