Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A Jekyll plugin to convert a .less file to .css
module Jekyll
# Compiled LESS CSS into CSS. You must specify an empty YAML front matter
# at the beginning of the file.
# .less -> .css
class LessConverter < Converter
safe true
priority :low
pygments_prefix "\n"
pygments_suffix "\n"
def setup
return if @setup
require 'less'
@setup = true
rescue LoadError
STDERR.puts 'You are missing a library required for less. Please run:'
STDERR.puts ' $ [sudo] gem install less'
raise"Missing dependency: less")
def matches(ext)
ext =~ /less/i
def output_ext(ext)
def convert(content)
rescue => e
puts "Less Exception: #{e.message}"
Copy link

ItsMeAra commented Apr 20, 2013

Thanks for this gist. I am running into an issue where the converted files are all blank and im getting this "Less Exception: uninitialized constant Less::Engine" Any idea what's causing that? Is there anything else I need to do aside from including this plugin in the plugin directory and putting empty yaml fron matter in my less files?

Copy link

KBalderson commented Jun 1, 2013

Looks like Less::Engine doesn't exist with the Less gem.

I modified this gist to use and .parse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment