HAML - TextMate Command
I have been enamored with Ruby lately and one of the gems that has been stuck in the back of my mind for a very long time was HAML. HAML is a really slick way to write some html code with Ruby hooks. If you’re a Ruby on Rails user you can convert all your .rhtml files into .haml files and really reduce the file’s contents to its pure essence. To see what I mean:
!!!
%html
%head
%title Simple Page
%body
#header
#sidebar
%ul.menu
#content
%h1 HAML is awesome
%p
It even performs Ruby!
= 50 * 10
#footer
%span{:style=>'text-align: center'} Joseph Pecoraro
Produces this super clean HTML:
Simple Page
HAML is awesome
It even performs Ruby!
500
Joseph Pecoraro
Now here is the catch. I don’t currently use Ruby on Rails, but I really value the quick translation of the easy to type HAML to valid and nicely formatted XHTML. I didn’t see a HAML function for TextMate that I wanted so I wrote my own command.
Download the Hamlize Command Here
Feel free to download it and customize the usage to your own workflow. I personally bound the command to ⌃⇧H which will let me choose between the Tidy command or Hamlize. Also the command will work on the selected text, or if nothing is selected it will do the entire document. Now I can whip out a simple XHTML template page in even less time.
Make sure to get HAML first. Just download the gem and you’re all set.
$ sudo gem install haml
Here are some nice HAML references to help show you even more powerful options:
HAML Tutorial
HAML Documentation


7. August 2008 um 18:31
Thanks - being new to HAML (and I AM using Rails), I like being able to do a quick check of the generated code.
8. October 2008 um 18:02
Excellent. I’ve been looking for something like this for a long time. Nice work. :)
13. October 2008 um 16:28
Awsome..
In conjunction with the TextMate HAML & SASS Bundles I couldn’t be happier
http://github.com/seaofclouds/sass-textmate-bundle/tree/master
http://macromates.com/svn/Bundles/trunk/Bundles/Ruby Haml.tmbundle