From: Adam Van Den Hoven Date: 2005-09-27T07:57:38+09:00 Subject: Re: Embedded Ruby and Tag Libs That's excellent. Now "all" we need is a parser to convert ... into av_table do ... end On 26-Sep-05, at 3:39 PM, Devin Mullins wrote: > 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_table do %> > <% 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 > > >