From: Brian Candler Date: 2009-03-24T19:40:23+09:00 Subject: Re: tagz-5.0.0 Ara Howard wrote: > tagz.rb is generates html, xml, or any sgml variant like a small > ninja > running across the backs of a herd of giraffes swatting of heads > like a > mark-up weedwacker. Looks interesting. Aside: people looking at this might also be interested in HAML. Several of your examples look very similar to how I use HAML with Sinatra. > in a helper > > def list_of_users > ul_(:class => 'users'){ > @users.each{|user| li_{ user }} > } > end def list_of_users haml :_list_of_users end ... @@ _list_of_users %ul{:class=>'users'} - @users.each do |user| %li&= user Alternatively it can be done inline: def list_of_users haml <'users'} - @users.each do |user| %li&= user HAML end > in a view > > <%= > table_{ > rows.each do |row| > tr_{ > row.each do |cell| > td_{ cell } > end > } > end > } > %> %table - rows.each do |row| %tr - row.each do |cell| %td&= cell > in a controller > > def ajax_responder > text = > tagz{ > table_{ > rows.each do |row| > tr_{ > row.each do |cell| > td_{ cell } > end > } > end > } > } > > render :text => text > end def ajax_responder haml :_ajax_table end ... @@ _ajax_table %table - rows.each do |row| %tr - row.each do |cell| %td&= cell I can see that tagz works particularly well where you want to generate HTML snippets directly inline with your code. The inline form of HAML is a bit icky because it needs to align with the left-hand edge. You could fix this with a helper, but I prefer partials because they are easily precompiled and cached. Regards, Brian. -- Posted via http://www.ruby-forum.com/.