From: "Ara.T.Howard" Date: 2005-07-17T14:12:46+09:00 Subject: Re: delaying string evaluation On Sun, 17 Jul 2005, Navindra Umanee wrote: > Devin Mullins wrote: >> >> Woo! >> >> >> <% @table.each do |row| %> >> >> <% row.each do |cell| %> >> >> <% end %> >> >> <% end %> >>
<%= cell %>
>> >> > > Indeed. This is what the same code looks like in Ruby syntax: > > > Woo! > > > #{@table.map do |row| > %{ > #{row.map do |cell| > %{} > end.join} > } > end.join} >
#{cell}
> > > > What do you think? It's close isn't it? But thanks for your example, I'm > slowing starting to see the point. and amrita is even nicer: ~ > cat a.rb require 'amrita/template' template = Amrita::TemplateText::new <<-html Woo!
html rows = [ { :foo => 42, :bar => 42.0 }, { :foo => 'forty-two', :bar => 'FORTY-TWO' }, ] template.expand STDOUT, :rows => rows ~ > ruby a.rb Woo!
42 42.0
forty-two FORTY-TWO
ahhhh. ;-) -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================