Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to process Bootstrap with less.rb outside of Rails

I'm attempting to create a standalone application (independent of the Rails asset pipeline) using less.rb to output CSS files based upon Twitter Bootstrap.

The following results in an empty document

parser = Less::Parser.new :paths => [Rails.root + '/public/bootstraps/twitter-bootstrap-857b8fb/less']

tree = parser.parse("@import 'bootstrap.less'")

tree.to_css 

Which results in an empty string being returned. I've tried variations of altering the @import to be the full path etc, with no success. I think I must be missing something simple.

like image 554
Mike Buckbee Avatar asked Jun 17 '12 05:06

Mike Buckbee


1 Answers

I believe you have an issue with how you are specifying your path. As far as I can tell, Less is looking for an array of String objects, not Path obejcts.

Use the following:

parser = Less::Parser.new paths: [Rails.root.join('public', 'bootstraps', 'twitter-bootstrap-857b8fb', 'less').to_s]

tree = parser.parse("@import 'bootstrap.less'")

tree.to_css 
like image 184
rudolph9 Avatar answered Nov 15 '22 09:11

rudolph9