From: Thomas Hurst Date: 2002-11-09T23:26:26+09:00 Subject: Re: An alternative HTML generation syntax * Philip Mak (pmak@aaanime.net) wrote: > I'm using Ruby to output HTML a lot these days. I know of these > methods: > > 1. Use CGI::Html4. Problem: Must use '+' all the time to join things. > If I forget a '+', everything in the block before the '+' will get > silently ignored since only the return value matters. I don't like these "tags are methods", um, methods. Frankly, they're almost as bad as using puts() as far as seperating markup from content generation. I've written a lot of PHP template engines, and I've had some nice ideas which PHP made quite difficult to implement; Ruby's flexibility could make for some interesting engines, IMO. Concider something like: t = FreakyTemplate.new('foo.tpl') t.head(:title => "Title", :author => "Me") t.body(:heading => "Article List") articles.each do |a| t.body.article(a) end print t Using the template: {block:head} {title} {/block} {block:body}

{heading}

{block:article(a)}

{a.title}

By {a.author}

{a.body}

{/block}
{/block} This closely mirrors an (unreleased) isotemplate engine I wrote in PHP. -- Thomas 'Freaky' Hurst - freaky@aagh.net - http://www.aagh.net/ - Woman: "Is Yoo-Hoo hyphenated?" Yogi Berra: "No, ma'am, its not even carbonated."