title: Conditionally closing a tag in HAML
body: <p>I'm iterating through a set of items and displaying them in lists nested in divs. The goal is to have a div for each day and within each div show the items for that day.</p>
  
  <p>How do I do this in HAML? I don't think I can (or should) conditionally close and create a new tag like I could in erb.</p>
  
  <p>I tried:</p>
  
  <pre><code>- @items.each do |item|
    - if item date is diff from previous make a new container
      .container
        %h2 #{item.date}
        = yield_content :display_item item
    - else
      = yield_content :display_item item
  </code></pre>
  
  <p>But this creates the following:</p>
  
  <pre><code>&lt;div class="container"&gt;
  &lt;h2&gt;01/28/2012&lt;/h2&gt;
        &lt;ul&gt;
              &lt;li&gt;
                ... item
          &lt;/li&gt;
        &lt;/ul&gt;
  &lt;/div&gt;
          &lt;li&gt;
          ...item
        &lt;/li&gt;
  </code></pre>
  
  <p>But I want the other item in the same div.
  I'm using ruby, sinatra (including the content_for helper)</p>