THT /
Introduction
Search:  


THT Introduction

THT provides self-contained web scripting. No Apache modules are required. In fact, there are no external dependancies! All you need is Tcl 8.3 or greater (releases from 2000 on should work).

If your ISP supports CGI and is running Linux, there is a good chance Tcl is already installed and you can start using THT immediately (see Installation). If you run your own site, Tcl is one of the easiest and most painless packages to build and install. (However, virtually every Linux distribution already includes Tcl, so building it is not usually required.)

THT can even use FastCGI if you have it, via stay-resident pages. If you don't have FastCGI, you can emulate it with SockCGI.

THT itself is written in just a few thousand lines of Tcl, leaving virtually everything open to inspection, correction and improvement. And for embedded use, Tcl is hard to beat.

Scripts

A THT script file uses the file extension .tht. Typically this is just plain HTML with Tcl code embedded inside <?tht ... ?> escapes. eg.

  
<H1 Demo</H1>
<?tht
    echo "<B>Hello world</B>"
?> 

Commands

In addition to the standard Tcl commands, THT currently provides builtin commands. Some of these are simple commands such as echo which is used to output HTML to the page. While others, such as html, are compound commands implemented using Mod. A Module is a namespace containing a collection of sub-commands. Some of these sub-commands may in turn be Modules, etc.

Variables

Currently THT uses several global array variables for runtime use. These include:

VariableDescription
ENVEnvironment variables.
QUERYElements from the query string.
THTVarious control variables.
COOKIESCookie name/value pairs.
FILESFile names from uploads.

See the ''Dump all' example in Examples for sample output.

Commented Blocks

THT may also be hidden in a document using <!--<?tht ... ?>--> (note there must be no spaces in between). Browsers will ignore the inline code but THT will process it just fine.

Security

For the security minded, THT scripts are easily secured within Safe-Tcl. Also procs in THT use introspective documentation: The documentation is extracted from the comment at the top of each proc using Tcl introspection mechanisims.

Performance

While no incredible claims will be made about THT performance, it is able to use FastCGI. If you think PHP or other embedded servers are unbeatable, perhaps you might like to read some of the links off of the FastCGI page. In particular: A Comparison of Portable Dynamic Web Content Technologies for the Apache Server. http://www.fastcgi.com/

© 2008 Peter MacDonald

Page last modified on February 02, 2010, at 03:12 PM