title: How to write a helper in Ruby on Rails to capture Haml blocks?
body: <p>I am writing a Rails helper method that will add wrapper html to captured content blocks and replace content_for method, such as</p>
  
  <pre><code>- content_for :header do
   //haml code
  </code></pre>
  
  <p>..would become</p>
  
  <pre><code>- content :header do
   //haml code
  </code></pre>
  
  <p>In order to do this I am using Haml and Ruby blocks. This is what it looks like</p>
  
  <pre><code>def content(name,&amp;block)
   content_for name do
     capture_haml do
       haml_tag "div",{:id=&gt;name.to_s} do
         haml_tag "div",{:id=&gt;"#{name.to_s}_group"} do
           block
         end  
       end    
     end      
   end  
  end
  </code></pre>
  
  <p>But I can't get this to work. There is no error message. It just doesn't show the block at all! I'm not sure what I am doing wrong. I'd appreciate a second opinion.</p>