def wrap(&block)
concat(content_tag(:div, capture(&block), :class =>
"generic_header"))
end
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.
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
concat):
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 "=".