From: Devin Mullins Date: 2005-09-27T07:39:09+09:00 Subject: Re: Embedded Ruby and Tag Libs Devin Mullins wrote: > Hi, Adam, > > (I, for instance, am not a fan of passing around _erbout.) I cleaned up the syntax, btw, with a dependency on my favorite Rails support class: require 'rubygems' require 'binding_of_caller' class AvTable def initialize(out) @out = out; @side = :odd end def av_trow @out << %Q{} yield @out << "" @side = (@side == :odd) ? :even : :odd end end def av_table(&blk) Binding.of_caller do |b| out = eval '_erbout', b out << "" AvTable.new(out).instance_eval &blk out << "
" end end ERB.new( < <% av_trow do %>...<% end %> <% av_trow do %>...<% end %> <% av_trow do %>...<% end %> <% av_trow do %>...<% end %> <% av_trow do %>...<% end %> <% end %> RHTML __END__ And, of course, you can replace do ... end with { ... } if you prefer. Yeah, you might need/want a different templating framework than yet exists for Ruby. I dunno. I hope somebody else responds who has experience in some of the other templating systems, 'cause I'm pretty much clueless. :) Devin