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