Use Tcl to create a Wiki page

Tcl can be used to create a complete Wiki page. This can be handy for dynamic content or showing the output of some Tcl script. The way to do it is to just create a new page that has a <!DOCTYPE TCLPART> as the first line (if you want the wiki menubar or <!DOCTYPE TCL> if you don't) and then Tcl code which [puts] some stuff to stdout. This is what gets rendered then.

You can also include Tcl code from another page into an existing Wiki page. For this, you use in "include" directive.

An example: on A Wiki page with only Tcl code, we have some Tcl code. You can view the page and it is very simple (you can also edit it using this direct edit link: https://wiki.tcl-lang.org/_edit/A+Wiki+page+with+only+Tcl+code. This is the source code on that page:

<!DOCTYPE TCL>

set text {This is a test on how to produce a page using Tcl code}
set number [expr {3*6}]

puts "$text ($number)"

This output can be included on this very page here using << include:A Wiki page with only Tcl code >> (without the spaces after the << and before the >>; these are just included to prevent rendering exactly here ...) like this:


This is a test on how to produce a page using Tcl code (18)


By the way. It does not matter if the Tcl wiki page was created with <!DOCTYPE TCL> or <!DOCTYPE TCLPART. It is the content of that page that get's included here, i.e. the Tcl doe only.