Just curious, but is it possible to create a helper that captures the content of a block. Specifically I'd love to be able to do something like this in Stasis (this is a simplified example):
In my ERB template:
<% show_for_version('4.0.0') do %>
<p>I would love to display HTML content here.</p>
<% end %>
I would like the HTML output to then look something like this:
<div class='version-4.0.4'>
<p>I would love to display HTML content here.</p>
</div>
I tried to implement this as a helper method in controller.rb but it does not seem to be doing anything. Here's the helper code I have:
helper do
def show_for_version(version, &block)
if block_given?
"<div class='version-#{version}'>#{yield block}</div>"
end
end
end
Is something like this possible? Any help would be mucho appreciated, thanks!