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:

    %title Simple Page
      %h1 HAML is awesome
        It even performs Ruby!
        = 50 * 10
      %span{:style=>'text-align: center'} Joseph Pecoraro

Produces this super clean HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    <title>Simple Page</title>
    <div id='header'>
    <div id='sidebar'>
      <ul class='menu'>
    <div id='content'>
      <h1>HAML is awesome</h1>
        It even performs Ruby!
    <div id='footer'>
      <span style='text-align: center'>Joseph Pecoraro</span>

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.

TextMate Hamlize 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

3 Responses


Keith on August 7, 2008 at 6:31 pm  #

Thanks – being new to HAML (and I AM using Rails), I like being able to do a quick check of the generated code.


Ross on October 8, 2008 at 6:02 pm  #

Excellent. I’ve been looking for something like this for a long time. Nice work. :)


Joe on October 13, 2008 at 4:28 pm  #


In conjunction with the TextMate HAML & SASS Bundles I couldn’t be happier

http://macromates.com/svn/Bundles/trunk/Bundles/Ruby Haml.tmbundle

Add a Comment