I am wanting make a helper for tag <table>. I am make follow. 1. def tabela(&block) 2. s = ''<table>'' 3. t = concat(s, block.binding) 4. t << ''</table>'' 5. end And call this: 1. <% tabela do %> 2. teste</br> 3. teste2</br> 4. <% end %> However this generate this code html 1. <table></table> How make for generate the block content? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Marcelo wrote:> I am wanting make a helper for tag <table>. I am make follow. > > 1. def tabela(&block) > 2. s = ''<table>'' > 3. t = concat(s, block.binding) > 4. t << ''</table>'' > 5. end > > And call this: > > 1. <% tabela do %> > 2. teste</br> > 3. teste2</br> > 4. <% end %> > > However this generate this code html > > 1. <table></table> > > How make for generate the block content?Your not actually executing the block. You need to "capture" the block, and then call "concat" on the whole string. See my blog post about block taking helpers for more info: http://beautifulpixel.com/articles/2007/02/23/helpers-and-blocks -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Try block.call. #binding only gets you the current variable binding and scope of the block, nothing gets executed. Jason On 3/14/07, Marcelo <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I am wanting make a helper for tag <table>. I am make follow. > > 1. def tabela(&block) > 2. s = ''<table>'' > 3. t = concat(s, block.binding) > 4. t << ''</table>'' > 5. end > > And call this: > > 1. <% tabela do %> > 2. teste</br> > 3. teste2</br> > 4. <% end %> > > However this generate this code html > > 1. <table></table> > > How make for generate the block content? > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---