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: <div> <div> <div class="content">CONTENT HERE</div> </div> </div> Thanks very much for reading. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 5 Feb 2011, at 16:43, Oliver Cat <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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> > tl;dr I basically want to pass a block to a helper and return something > like: > <div> > <div> > <div class="content">CONTENT HERE</div> > </div> > </div> > > > Thanks very much for reading. > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.