Skip to content

Instantly share code, notes, and snippets.

@pyk
Forked from KBalderson/less_converter.rb
Last active January 2, 2016 18:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyk/8346584 to your computer and use it in GitHub Desktop.
Save pyk/8346584 to your computer and use it in GitHub Desktop.
Using LESS on Jekyll site . for using intructions see here https://kippt.com/bayu/notes/clips/18862841
module Jekyll
class LessConverter < Converter
safe true
priority :high
def setup
return if @setup
require 'less'
@setup = true
rescue LoadError
STDERR.puts 'You are missing the library required for less. Please run:'
STDERR.puts ' $ [sudo] gem install less'
raise FatalException.new("Missing dependency: less")
end
def matches(ext)
ext =~ /less|lcss/i
end
def output_ext(ext)
".css"
end
def convert(content)
setup
begin
parser = Less::Parser.new
parser.parse(content).to_css
rescue => e
puts "Less Exception: #{e.message}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment