Class: Jekyll::Less::LessCssFile
- Inherits:
-
StaticFile
- Object
- StaticFile
- Jekyll::Less::LessCssFile
- Defined in:
- lib/jekyll-less.rb
Instance Method Summary collapse
-
#destination(dest) ⇒ Object
Obtain destination path.
-
#write(dest) ⇒ Object
Convert the less file into a css file.
Instance Method Details
#destination(dest) ⇒ Object
Obtain destination path.
+dest+ is the String path to the destination dir
Returns destination file path.
13 14 15 |
# File 'lib/jekyll-less.rb', line 13 def destination(dest) File.join(dest, @dir, @name.sub(/less$/, 'css')) end |
#write(dest) ⇒ Object
Convert the less 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).
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jekyll-less.rb', line 21 def write(dest) dest_path = destination(dest) return false if File.exist? dest_path and !modified? @@mtimes[path] = mtime FileUtils.mkdir_p(File.dirname(dest_path)) begin content = File.read(path) content = ::Less::Parser.new({:paths => [File.dirname(path)]}).parse(content).to_css File.open(dest_path, 'w') do |f| f.write(content) end rescue => e STDERR.puts "Less Exception: #{e.}" end true end |