Haml/Sass 2.2 Released

Posted July 6, 2009

Haml/Sass 2.2 (named Powerful Penny) has finally been released! And this is quite a release.

Get it by running

sudo gem update haml

New Features

For a full listing of features, you’ll need to check out the Haml and Sass changelogs, but I’ll talk about a few of the most exciting ones here.

Flexible Indentation

Both languages now allow indentation other than two spaces. Two spaces are still recommended, especially for Haml code (since two spaces is the Ruby standard), but it’s no longer required. The only requirement now is that the indentation remain consistent within a document and that you not mix tabs and spaces.

New Attribute Syntax

The biggest addition to Haml is a new syntax for attributes, based on the HTML attribute syntax. In order to distinguish these from hash-style attributes, they use () rather than {}.

%a(href="http://sass-lang.com" title="A link!") I like links.

This new syntax is both more concise and more portable than the hash-style syntax. It doesn’t allow for attribute methods or for arbitrary Ruby code to be (easily) used as attribute values, though, so the hash-style syntax will still stick around. For more details, see the changelog.

Sass Power

Sass 2.2 takes the variables, mixins, and arithmetic from previous versions and brings them to a new level. Sass is now practically a programming language in its own right. It now supports mixins with arguments, loops, and if/else statements. In addition, variables may be used to dynamically define selectors and attribute names. It’s this kind of power that makes the Compass Sass framework possible.

Other Cool New Things

New Websites

The Haml website has moved to its own domain, haml-lang.com, and Sass finally has a site all to itself, sass-lang.com! Not only that, but I’ve gone over all the content on the websites to make sure it’s up-to-date. Look forward to even more useful documentation showing up there soon.

YARD

I’ve migrated all the documentation for Haml and Sass to the YARD documentation system. YARD is a fantastic tool. It brings structure and sense to API documentation, and it allows documentation writers to finally escape from the bottomless pit of RDoc’s terrible markup. Loren Segal, the maintainer, was wonderfully accommodating of Haml’s needs. I have high hopes for YARD becoming the standard Ruby documentation tool not too long from now.

Thanks!

First of all, I can’t thank Sass core team member Chris Eppstein enough. He drove many of the powerful additions to the language, and has put up with me endlessly nitpicking his code and ideas with admirable grace. On top of his coding, he’s done more than anyone else (including, I fear, myself) to spread the word about Sass to everyone he can, even outside the Ruby community. Thanks, Chris.

Second, creator of Haml and Sass Hampton Catlin certainly deserves a mention. Although he’s not taking an active role in development these days, from his head first sprang the idea to take HTML and CSS and just start deleting.

Next I’d like to thank everyone else who contributed code to this release:

  • Carlos Villela
  • Christopher Redinger
  • Federico Builes
  • Jacques Crocker
  • Jim Garvin
  • Joe Wasson
  • Juampi Rodriguez
  • kematzy
  • Laszlo Bacsi
  • Max Aller
  • Michael Fellinger
  • Michael S. Klishin
  • Mislav Marohnić
  • Paul Barry
  • Phil Hagelberg
  • S. Brent Faulkner
  • Shingo Noguchi
  • Stefan Penner
  • Stephen Sykes
  • Todd Tyree
  • Will Farrington
  • Wincent Colaiuta

Finally, thanks to everyone on the mailing list and the IRC channel, everyone who submitted a bug report or made a feature request, and everyone who helped someone else solve a problem. It’s Haml’s vibrant community that makes this all worth it. You guys rock.

Somebee said July 06, 2009:

Thank you for yet another awesome release! I don’t know how you manage to keep working so much on fantastic haml/sass stuff, but I def’ hope you’ll keep it up in the future!

DAddYE said July 08, 2009:

Great work! Thanks!

@nicktea said July 08, 2009:

Great stuff guys! I can’t wait to get rocking with your new release!

ben_ said July 09, 2009:

Is the a typo on the http://haml-lang.com/ page in the example? In line 2 theres this haml code .left.column which becomes this html class left_column

and in line 5 there is this haml code .right.column which becomes magically this html class right column

Where’s the difference?

Nathan said July 09, 2009:

ben_: That is indeed a typo. I’ve fixed it; thanks for pointing it out.

Chris said July 13, 2009:

Is it possible to use Sass separate of ruby? f.e. offering a downloadable exe would make it more easy to use for other server side languages!

Nathan said July 14, 2009:

Yes, it’s definitely possible. Right now the best way to do it is to install Ruby and use RubyGems to install the executable – this makes the most sense for OSX and Linux, although it’s a bit more of a pain in Windows. In the future we may provide some sort of Windows installer.

Zifnab said August 08, 2009:

Hi Nathan….

So this might be an odd question but is there a good way to handle something like this?

div
  &.row
    width = (!row_width = 200px)

  &.row_title
    width = (!title_width = 100px)

  &.row_field
    width = !row_width - !title_width

Or should I just throw the variable definitions in their own line above instead of trying to define the variable and assign the attribute in the same line? (This code throws a syntax error about expecting a right parenthesis but receiving an equal sign instead)

Nathan said August 08, 2009:

Assignments need to be on their own line. SassScript doesn’t allow assignments as expressions.

In the future, we may have a syntax for using attribute values in SassScript.

Zifnab said August 08, 2009:

That would be awesome :p If I could do something like…

div
  &.row
    width = 200px

  &.row_title
    width = 100px

  &.row_field
    width = !&.row.width - !&.row_title.width

It would add tons of flexibility. But honestly what’s available right now in SASS is quite amazing, kudos to you :)

Nathan said August 09, 2009:

However awesome Sass gets, it’s always worth making it more awesome!

Make your comments snazzy with Textile!