Haml 2.0.4 Incompatible with Rails 2.2

I’ve recently updated several projects to Rails 2.2. The upgrade process was very smooth and fast, and everything seemed to be just fine until today: when I visited some pages of one project, I noticed some parts on serval pages were missing.

What happened? I didn’t change any MVC code.

A quick check led to this result: some content_tag and div_for calls don’t work anymore. Take this snippet for example:

- div_for @post do
    = h @post.title
    = simple_format(h @post.body)

Haml 2.0.4 was used in this rail project. I doubted Haml might be not compatible with Rails 2.2. To confirm this, I created a rails app, and the following just works with ERB (the first one is an example from the Rails rdoc):

<% content_tag :div, :class => "strong" do -%>
  Hello world!
<% end -%>

<% div_for @post do -%>
  <h2><%= h @post.title %></h2>
  <div><%= simple_format(h @post.body)</div>
<% end -%>

This needs further investigation. If it’s indeed Haml’s problem, hope there’ll be a fix in Edge Haml ASAP.

Update (Nov 29, 2008): Haml 2.0.5 released and this issue has been fixed.