The form builder for custom tags does not work the way I would expect any kind of Ruby form builder to behave. Consider this code:
content_tag :div do
content_tag :h1, 'A'
content_tag :h2, 'B'
end
From this I expect:
<div><h1>A</h1><h2>B</h2></div>
But I get:
<div><h2>B</h2></div>
The div content tag only returns the output from the last content_tag. This is very strange to me.
Now if I define content tags outside of the div block I get the result I expect:
a = content_tag :h1, 'A'
b = content_tag :h2, 'B'
content_tag :div do
a + b
end
This outputs:
<div><h1>A</h1><h2>B</h2></div>
Is this expected behaviour or a bug? I have used a lot of different form builders in Ruby, and this is the first one that behaves like this, so it seems very counter-intuitive to me.