same html elements rendering twice on page

hey all,

My index.html.haml:

- wrap do
  - page_title "Teams List View"


  def page_title(title)
    content_tag :h1, title

  def wrap(&block)
    concat(content_tag(:div, capture(&block), :class =>

I load in browser and get:
<div class="generic_header"><h1>Teams List View</h1></div>
<div class="generic_header"><h1>Teams List View</h1></div>

It's rendered twice. Not sure why. I invoke the wrap iterator, passing
a block into the argument list, wrap receivers it as a reference, then
I concat a div, use capture to render the page title as nested within
div, and assign div class. Not sure what I am doing wrong.

What happens if you get rid of concat()?

By the way, if you put some html at the top of the page, e.g.

%p Index.html.haml
- wrap do
  - page_title "Teams List View"

Your wrap() method will double render the whole page.

Based on my experiments with haml, I would never consider using a
multiline ruby block that contains a rails helper. The results are too
unpredictable. Both of these syntaxes do what you want (without

- wrap do
  - page_title "Teams List View"

- wrap do
  = page_title "Teams List View"

Note that in this code:

content_tag(:div, capture(&block), :class =>"generic_header")

...capture() does indirectly what does directly.

thanks for response, and the explanation of capture(). When I removed
the concat from the helper, the title stopped rendering twice. I
thought the concat was used to concatenate the two blocks of html, but
after reading documentation it appears it's to render haml without
using "=".

It seems to me that the = sign in haml is arbitrary and capricious. For
instance, how does the syntax:

- wrap do
  - page_title "Teams List View"

result in anything being added to the page?