Skip to content

maccman/less-rb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

About

Less using ExecJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages