jWebTools is an open-source, pure Tcl extension with tools and utilities for constructing simple or elaborate websites. The building blocks in jWebTools provide a basis for producing almost any kind of web page. Authors have the option to write pages in object-oriented or conventional Tcl syntax, either way both static and dynamic content are supported. jWebTools is aimed primarily at experienced Tcl programmers with good knowledge of html, css, javascript, client-server practices and administration.

Also jWebTools has capabilities aside from building websites, the project contains a number of components with few or no internal dependencies that can readily be applied in general Tcl programming. See list of features below.

Fossil repohttps://thinairarts.com/fossil/jwebtools-src/index

2022-08-01: Update to jWebTools v1.0.7. Changes: restructured utilities, revised email notification, numerous bug fixes. See changes.md for list of updates.

Major features of jWebTools:

  • OO and non-oo styles of programming are supported
  • Compound or composite elements
    • Menu (vertical, cascading main menu)
    • WebImg (figure/image, highly configurable)
    • Slider (image display widget, uses WebImg)
  • Visitor contact page. A predefined page for visitor messages and comment system.
  • Commenting capability. Basic per page commenting (with moderator option) is easy to set up and use.
  • Web server. Primarily designed as backend/reverse proxy for dynamic content. Also works as a general purpose web server during development.
  • Log. Logging for web server.
  • Smtp. Email capability, used for notification of administrator when visitor leaves a message or makes a comment. Also provides a standalone command-line mailer utility.
  • Pmake. A make-like facility for jWebTools.
  • Config. Easy configuration for jWebTools paths, files, etc.
  • CSS manipulation functions, includes combining and minifying css files.
  • CmdArg. CmdArg provides named arguments for any proc or method. CmdArg allows calls to a proc/method to use a Tcl-like convention. Similar to Tcl commands, named arguments are preceded by '-'. Interface permits unlimited named arguments. Enhances usability and employed extensively in jWebTools.
  • Misc utils. Util.tcl, Resource.tcl, stack.tcl, Bool.tcl implement a number of routines applicable in general Tcl coding.

For details see website and fossil repo. Documentation is available online as well as in PDF format (cf., archive documentation directory or fossil repo).

Using jWebTools:

Web elements are represented by TclOO classes. For example, the <html> tag is rendered by the Html class. Similarly, the Body class emits the <body> tag with attributes and contents of <body>.

A web page is created by subclassing Html. Alternatively in a namespace using Tag::* namespace procedures. jWebTools provides the ::Tag namespace which defines procs that return "ready to use" element objects. For example, Tag::Html: (note the trailing colon) when invoked returns an Html object.

Using the object-oriented approach:

package require jWebTools
    oo::class create MyPage {
        superclass Html

        constructor {} {
            next -head [my mkHead] -body [my mkBody] \
                outfile mypage.html
        method mkHead {} {
            Head new -Es [subst {
                [Title new "My Great Page"]
                [Link new -href /css/mypage.css -type /text/css]
        method mkBody {} {
            Body new -Es [subst {
                [Div new ...]
    # Render output (mypage.html)
    [MyPage new] write

Same, using namespace notation:

    package require jWebTools
    namespace eval MyPage {
        namespace import ::Tag::*

        proc construct {} {
            variable html [Html: -head [mkHead] -body [mkBody] \
                outfile mypage.html]
        proc render {} {
            variable html
            $html write
        proc mkHead {} {
            Head: -Es [subst {
                [Title: "My Great Page"]
                [Link: -href /css/mypage.css -type /text/css]
        proc mkBody {} {
            Body: -Es [subst {
                [Div: ...]
    # Render output (mypage.html)

The *.tcl files in the Examples directory of the fossil repo show complete class and namespace versions of the same web page. The Demo directory README gives step-by-step instructions for rendering html output and using the jWebTools web server to view the page in a browser.