= Rack::Less == Description A better way to use LESS CSS in Ruby web apps. == Installation $ gem install rack-less == Basic Usage Rack::Less is implemented as a piece of Rack middleware and can be used with any Rack-based application. If your application includes a rackup (`.ru`) file or uses Rack::Builder to construct the application pipeline, simply require and use as follows: require 'rack/less' use Rack::Less, :source => 'app/less' :compress => true run app == Using with Rails Add this to your `config/environment.rb`: config.middleware.use "Rack::Less" You should now see `Rack::Less` listed in the middleware pipeline: rake middleware == Available Options [] * *root* ["."]: the app root. the reference point for the source and public options. * *source* ['app/stylesheets']: the path (relative to the root) where LESS files are located * *public* ['public']: the path (relative to the root) where LESS files are located * *hosted_at* ['/stylesheets']: the public HTTP root path for stylesheets * *cache* [false]: whether to cache the compilation output to a corresponding file in the hosted_root * *compress* [false]: whether to remove extraneous whitespace from compilation output == Combinations At times, it is useful to combine many stylesheets and serve them as one resource. Rails' has a helper for this: stylesheet_link_tag 'one', two', :cache => 'app' Rack::Less supports this concept by providing combinations. Combinations are specified using a hash, where the key is the combined resource name and the value is an array of stylesheets to combine as that resource. For example: Rack::Less.combinations = { 'app' => ['one', 'two'] } would service the above stylesheet_link_tag. Even better, you could re-factor the stylesheet_link_tag as follows to DRY it up: stylesheet_link_tag Rack::Less.combinations['app'], :cache => 'app' * *combine* [{}]: directives for combining the ouput of one or more LESS compilations, for example: { 'app' => ['one', 'two', 'three'] } will direct Rack::Less to respond to a request for app.css with the concatenated output of compiling one.less, two.less, and three.less == Links GitHub: http://github.com/kelredd/rack-less Less: http://lesscss.org == License Copyright (c) 2010 Kelly Redding (mailto:kelly@kelredd.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.