Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Less using ExecJS
Ruby
Branch: master
Failed to load latest commit information.
bin
lib
spec
.gitignore
.gitmodules
Gemfile
LICENSE
README.md
Rakefile
less-rb.gemspec

README.md

less-rb

less-rb allows you to compile Less CSS files from Ruby.

To install:

gem install less-rb

To use:

require 'less-rb'
Less::Parser.compile("body { background: darken(#CCC, 10%) }")

These bindings also integrate with Tilt and Sprockets, so work seamlessly with Rails.

Requirements

Node.js needs to be installed, and in the path.

About

These are Ruby bindings for the next generation LESS, which is implemented in JavaScript.

These are separate from the official bindings, as they've been ported to ExecJS. This means you don't have to re-compile v8 every deploy.

For more information, visit http://lesscss.org.

Usage

less-rb exposes the less.Parser constructor to ruby code via Less::Parser. You can instate it context free:

parser = Less::Parser.new

or with configuration options:

parser = Less::Parser.new :paths => ['./lib', 'other/lib'], :filename => 'mystyles.less'

Once you have a parser instantiated, you can parse code to get your AST !

tree = parser.parse(".class {width: 1+1}") # => Less::Tree
tree.to_css #=> .class {\n  width: 2;\n}\n
tree.to_css(:compress => true) #=> .class{width:2;}

There's a shortcut for this whole routine:

Less::Parser.compile(css, options)

Credits

This library was ported from less.rb also using the Apache License. It was created by Alex MacCaw (@maccman).

Something went wrong with that request. Please try again.