Need help with concat and binding

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…

bla
bla2

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

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 M. [email protected]