TclHTML

Problem. My Internet account comes with 20 MiB of web space, but does not allow for CGI scripts -- static HTML only. I needed a way to produce a slew of HTML pages with repeated elements (such as navigation bars), without resorting to doing it all myself with cut & paste -- a tedious and error-prone process at best.

Solution. Inspired by Don Libe's paper on using Tcl to program CGI scripts, I applied the same approach to generating my HTML files. After several rewrites of the Tcl macro library I have decided to have a go at wrapping it up as a little Tcl package. Thus TclHTML.


Here's an example of TclHTML at work. If you are familiar with Tcl and HTML, you should be able to get the gist of what is going on: for each HTML tag there is a Tcl command which generates it.

ul {
    li "First one thing,"
    li "Then another"
}
<ul>
  <li>First one thing,</li>
  <li>Then another</li>
</ul>
  • First one thing,
  • Then another

One of the attractions of Tcl for this application is that it allows me to define new control structures to match the structure of HTML documents. In the above example, the Tcl command ul takes a Tcl script as its last argument, which contains li commands to generate the content of the ul element.

For a longer example, try the Tcl code for this page, and compare it with the HTML code (`View Source').

TclHTML manual.

Hosted by SourceForge