New HTML Toolkit

B

Bill Atkins

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.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.

<html>
<head>
<title>
<link rel="stylesheet" href="style/rhtk.css">
</head>
<body>
<h1 class="modern">Here's a sample header.</h1>
<table>
<!-- main table begin -->
<tr>
<td>
1
</td>
<td>
2
</td>
<td>
3
</td>
</tr>
<tr>
<td>
4
</td>
<td>
5
</td>
<td>
6
</td>
</tr>
<!-- main table end -->
that's all for now
</body>
</html>

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top