You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 lastcontent_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.
The text was updated successfully, but these errors were encountered:
which when called are automatically appended to the form content.
For other helpers such as content_tag, they'll follow regular ruby logic which is to only use the result of the final line of the block. In order to include both, one option is to call concat to append each line to the output buffer.
The reason for doing it this way in Trestle is that some helpers (icon is probably the best example) can be passed to form helpers and they shouldn't be appended to the form content just by being called.
I am exploring approaches such as those take in Phlex, though I'm not sure yet if that is the way to go.
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:
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 lastcontent_tag
. This is very strange to me.Now if I define content tags outside of the div block I get the result I expect:
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.
The text was updated successfully, but these errors were encountered: