Writing a block helper (using concat)

Hi all,
I’m trying to write a helper method which takes an argument and a block.
The markup returned should be a div, with a header (the title argument)
and the block string inside it (there will be other markup, for things
like rounded corners etc).

I’m getting confused about the behavior of the concat method, that I’ve
seen in some examples.
Currently, my helper method looks like this:

2 def render_box(title = ‘’, options = {}, &block)
3 content = capture(&block)
4 concat(content)
5 end

but for some reason, that returns a duplicate of my page markup, up
until the helper is called (see here: http://pastebin.com/Sx63zww8)

Can anybody explain what’s going on with concat? I would expect it
simply takes two arguments and returns the joined string, but it looks
as though it’s interfering with rails’ own output buffer.

tl;dr I basically want to pass a block to a helper and return something
like:

CONTENT HERE

Thanks very much for reading.

On 5 Feb 2011, at 16:43, Oliver C. [email protected] wrote:

Can anybody explain what’s going on with concat? I would expect it
simply takes two arguments and returns the joined string, but it looks
as though it’s interfering with rails’ own output buffer.

How are you calling your helper?
concat appends text to the output buffer, and probably returns that same
buffer.
If you are calling it with <%= then you’re rails would then append the
return value of your helper (which is the return value of concat) to the
output, in addition to the append done by your call to concat

Fred