From: dejaspam@... (Bill Atkins) Date: 2004-04-15T00:09:14+09:00 Subject: New HTML Toolkit Idea I was thinking today about how much I hate writing scripts to generate HTML and I sat down and wrote some code. I'm thinking about making a simple toolkit to generate HTML in an abstract way. Here's my sample code: # tests a simple HTML generation toolkit - this is how a working script ought to work data = [[1, 2, 3], [4, 5, 6]] puts RHTk.new do title "A Test of RHTk - The Ruby HTML ToolKit" include_css "style/rhtk.css" body do header1 "Here's a sample header", :class => 'modern' table do data.each do |i| row do data[i].each do |d| column d end end end end out "that's all for now" end end The RHTk constructor assembles a string of HTML based on all the code executed within its block. The output would be neatly tabified, giving you something like this:
| 1 | 2 | 3 |
| 4 | 5 | 6 |