Check out the usage here:
http://blog.imperialdune.com/2007/3/27/dirty-views-clean-them-up
Basically you need to do something like:
def header(content, *options, &block)
  concat(content, block.binding)
end
Good luck.
-s
On Apr 6, 4:30 am, Joshua Muheim
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hi all
>
> I want to create a HTML table builder that outputs HTML code.
>
> <% incense_table do |table| -%>
>   <% table.row do |row| -%>
>     <%= row.header(''bla'') %>
>   <% end -%>
>   <% table.row do |row| -%>
>     <%= row.data(''bla2'') %>
>   <% end -%>
> <% end -%>
>
> ...should result in...
>
> <table>
>   <tr>
>     <th>bla</th>
>   </tr>
>   <tr>
>     <td>bla2</td>
>   </tr>
> </table>
>
> I''ve come so far (code is in application_helper.rb):
>
> module ApplicationHelper
>   def incense_table(options = {}, &block)
>     yield(IncenseTableBuilder.new)
>   end
> end
>
> class IncenseTableBuilder
>   include ActionView::Helpers::TextHelper
>
>   def row
>     yield(IncenseTableBuilder::Row.new)
>   end
> end
>
> class IncenseTableBuilder::Row
>   include ActionView::Helpers::TextHelper
>
>   def header(content, *options)
>     concat(content, block.binding)
>   end
>
>   def data(content, *options)
>     concat(content, block.binding)
>   end
> end
>
> Sadly I don''t really get it how to use the concat method... I need
a
> "binding" as 2nd parameter but don''t have a clue what
this should be.
>
> Anyone could show me a step or two into the right direction?
>
> Thanks a lot,
> Josh
>
> --
> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---