I’m trying to design a helper for HAML, which would work like this:
%table
- tabular(items) do |i|
%tr
%td
= i[:title]
I expect it to render the following HTML:
<table>
<tr><td>first</td></tr>
<tr><td>second</td></tr>
<tr><td>Total: 2</td></tr> <!-- This is not an item! -->
</table>
I’m trying this approach, but doesn’t work:
def tabular(items)
total = 0
items.each do |i|
total += 1
yield i
end
"<tr>Total: #{total}</tr>" # this doesn't print :(
end