Haml/Sass 3 Release Candidate 1 Released

Posted April 26, 2010

To install:

gem install haml --pre

The release of RC 1 marks the last leg of the journey to the full release. Features are now frozen; all development effort until version 3 is released will go into bug fixes and other such minor improvements.

RC 1 itself does bring some very exciting goodies for both Haml and Sass, though. For a full list, see the Haml changelog and Sass changelog, but there are two in particular that are especially interesting.

Easy Ruby Multiline

Haml’s multiline syntax, placing a | at the end of each line of a multiline sequence, is intentionally annoying and difficult to work with. This is to counter the temptation to put lots of logic and code into the template: logic belongs in the model, controller, or helpers. Putting it there will result in cleaner, easier-to-read, and more concise templates.

However, there are occasions when even just calling a helper takes a lot of Ruby. This code isn’t actually business logic; it’s information that belongs in the template, just expressed in Ruby. We don’t want to discourage this, so it’s now possible to do without |. Any Ruby expression can be broken across multiple lines wherever there’s a comma. For example:

= link_to_remote "Add to cart",
    :url => { :action => "add", :id => product.id },
    :update => { :success => "cart", :failure => "error" }

Selector Inheritance with @extend

Probably the coolest feature in all of Sass 3, the new @extend directive allows one selector to inherit all the styles of another. This goes way beyond mixins; any style written for the extended selector will also work for the extending selector. For example:

.error {
  border: 1px #f00;
  background-color: #fdd;
}
.error.intrusion {
  background-image: url("/image/hacked.png");
}
.seriousError {
  @extend .error;
  border-width: 3px;
}

is compiled to:

.error, .seriousError {
  border: 1px #f00;
  background-color: #fdd; }

.error.intrusion, .seriousError.intrusion {
  background-image: url("/image/hacked.png"); }

.seriousError {
  border-width: 3px; }

For more details, see my blog post on @extend (to be posted momentarily) and the reference documentation.

Schedule

This release is three weeks later than my most ambitious goal, and only five days before my hard-and-fast deadline. This is largely because the beta process took longer than expected; foolishly, I hadn’t factored in how much time it would take to address all the bugs that popped up.

Since there will be no more new features added to Haml/Sass 3, though, I can guarantee the schedule from here on out. I need to allow some time for bug reports to come in and be addressed before the full version is released; two weeks should do nicely. Thus, Haml/Sass 3 will be released on May 10th.

Svoop said April 27, 2010:

Easy Ruby multiline, gorgeous! I remember the idea not being very popular when Jacques suggested it in the groups. Can’t wait to kick these pipes.

Steve said April 27, 2010:

Very handy, thank you very much

WT said April 28, 2010:

Wow, the gem is already at RC 2.

Phil Crosby said April 28, 2010:

Sass 3 is really promising. Thanks for all the hard work.

Make your comments snazzy with Textile!