Sunday, November 18, 2007

Native Sass Support for Merb

Nathan Weizenbaum aka nex3, a contributer to the awesome haml template system has just put support for using Sass in merb into the stable branch of Haml.

Haml has been supported in merb for a long time, longer than I've been involved with merb for sure. Sass was lacking though... Until Now :)

Before you can use Sass in Merb, you'll probably need to get the latest Haml.
sudo gem install haml
To use Sass in your Merb App it works the same way as in Rails. Put your Sass templates into public/stylesheets/sass
public/stylesheets/sass/my_style_sheet.sass
and include the css in the head of your layout application.html.*
css_include_tag :my_style_sheet
The only thing left to do now is to declare the dependency. In
config/dependencies.rb
include the line
dependency "haml"
Your app will now happily use your Sass templates, updated when you change them in development, but compiled only once during production. Sweet :)