CAU 25-Nov-2005: I finally got around to putting this page together. Something I've been meaning to do for at least 6 months.
THP is a way of embedding Tcl into HTML.
The requirements were quite straight forward. Some features are fairly obvious, others less so:
<%tcl while {$i<10} { %><B>Repeated line</B><BR><%tcl } %>
Why THP? Well, it's a play on the PHP name - (T)cl (H)ypertext (P)reprocessor
I've been using THP now for a little while, tweaking where necessary, and think that it generally fits what it was supposed to do.
THP has been tested on:
I had some fun putting the starpack version together and figuring out IIS for the first time. Getting THP working with Tclhttpd outside of the cgi-bin directory was a challenge too, but it works a treat! ...more details to follow.
THP evaluates everything in an interp before returning any resulting HTML to the client. I've aliased the "puts" command to give more control (THP can be used in debug mode on the command line using filenames as arguments) and it removes the need to use "puts -nonewline" frequently. There's also an "include" command which is more flexible than "source" or "open" to include the contents of anthother script or text file at that point in the markup.
THP also reads a file named .thprc (or thp.ini on windows platforms) and interprets this before anything else, allowing the developer to set variables or redirects quite easily.
Check out a description and example at [L1 ]
SMSM 04-16-16, Using Firefox 38, on a PPC Mac OS 10.5, the example at [L2 ] fails with 500.
It might make sense to see if you could utilize the standalone Rivet stuff. It's capable of doing a lot of what you require (maybe all of it, I don't recall), including parsing, including files, and so on.
Standalone? Does Rivet work without Apache? I've looked at Rivet in the past and although it has the advantage of a persistent interpreter, I thought it only worked with Apache.
THP does have its overhead of being run in a new interpreter for each page the client requests (as do most other CGI scripts using Tcl/Perl/Python, etc), but it's as portable and as easy to learn as Tcl, does pretty much what Rivet does and only three new commands are defined, two of which can be ignored if the user wishes.
It is up to the developer to decide how they get at GET and POST variables. As ncgi is available in tcllib, that shouldn't be a problem for most folks. ncgi is my preferred method: simply use
package require ncgi
inside your script. --CAU
schlenk Rivet has all the stuff needed to make it work outside of Apache, including a pure Tcl Rivet parser, parsing the special Rivet markup. I have an ncgi based application using rivet for page templating, works perfectly. One just needs to write some ncgi wrappers to setup the environment expected by standard Rivet pages.
See also: