Sass Supports Rack

Posted November 22, 2009

I’ve just released Haml and Sass 2.2.14. There are a bunch of useful changes in there; a few bug fixes, a few very minor feature additions. But there’s one feature in particular that’s more exciting than the rest: Sass now has native support for all Rack-based frameworks.

Just put this in your config.ru:
require 'sass/plugin/rack'
use Sass::Plugin::Rack

The Sass Rack plugin works just like the Rails and Merb plugins. Every request, it looks for Sass files in public/stylesheets/sass and compiles them to CSS files in public/stylesheets if necessary. These paths can be configured like so:

Sass::Plugin.options[:css_location] = "./stylesheets" 
Sass::Plugin.options[:template_location] = "./sass"

See the Sass reference for a full listing of available options.

For now, using Rack support is completely optional. It’s never loaded unless the user explicitly specifies, as above. Rails and Merb will continue to use their default plugins for version 2.2.x. For version 2.4, Rails versions that support Rack will use the Rack plugin, although Merb may not.

Geoffrey Grosenbach said November 22, 2009:

Beautiful! I’m doing more work with Sinatra lately and this will make it even easier to use Sass.

Nick Hammond said November 23, 2009:

Awesome, great addition to Sass.

Thibaut Barrère said November 23, 2009:

This is brilliant – and coming handy, as I want to use it with Sinatra. Thanks for your work!

Michelangelo Altamore said December 01, 2009:

Whooa! A clean and handy plugin to use sass with rack based framworks! Nathan, thank you for your high quality work!

Make your comments snazzy with Textile!