New HTML Toolkit

I was thinking today about how much I hate writing programs to
generate HTML, so I sat down and wrote some code. There’s currently
nothing to make this work - it’s just an idea

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
name "main table"
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 would return a string, all neatly tabified.

Here's a sample header.

that's all for now

The generation wouldn’t necessarily be sequential. The title and name
methods would store attributes and then everything would be converted
to a string at once.

I’d also like to add some kind of system for dealing with sessions and
forms. Possibly incorporating Borges into this would be a good idea.

I know that CGI.rb has something similar to this, but I’m intending
this to be a whole framework, rather than just some HTML generation
routines.

Any thoughts on this?

Bill Atkins

1 2 3
4 5 6

I was thinking today about how much I hate writing programs to
generate HTML, so I sat down and wrote some code. There’s currently
nothing to make this work - it’s just an idea

  header1 "Here's a sample header", :class => 'modern'

Setting attributes in this manner can lead to unreadable code.

The generation wouldn’t necessarily be sequential. The title and name
methods would store attributes and then everything would be converted
to a string at once.

It looks like you’d then have to create a structure first, then render
it to HTML when it is complete.

I’d also like to add some kind of system for dealing with sessions and
forms. Possibly incorporating Borges into this would be a good idea.

Well, I’ve already ported the hard part of your framework in Borges
(simple HTML generation, render from a pre-built structure). You can
find this code here:

http://rubyforge.org/cgi-bin/viewcvs/cgi/viewcvs.cgi/borges/lib/Borges/HTML/?cvsroot=borges

What it does not do is pretty-print the HTML, because nobody working on
Seaside found it worth the effort to get it right. Instead you just get
a single long string.

···

Bill Atkins (dejaspam@batkins.com) wrote:


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04