A Tcl template works by mixing Tcl code into normal HTML pages. The server uses the Tcl subst command to replace the Tcl code and variable references with their results and values. Here are a few examples:
|[Httpd_Version]||3.5.1 May 27, 2004|
|[clock format [clock seconds]]||Fri Jun 23 22:34:07 UTC 2017|
|[expr 7 * 826]||5782|
There are two template systems provided by the Doc module: tml and subst templates. They both work in a similar way to replace in-line Tcl, but they differ in the setup done before a page is processed.
The ".tml" template system provides caching of template results in static ".html" files. This saves the cost of re-processing the template each time you access the file. By default, the file page.html contains the cached results of processing the file page.tml. If the page.tml page is modified, the cached copy is regenerated. To get the cache, you have to ask for the page.html file. The server automatically checks to see if there is a corresponding page.tml file, processes the template, caches the result in page.html, and returns the result.
However, you don't want to cache if the page must be processed on each access. If you don't want your templates cached, put a call to
[Doc_Dynamic]into your page. That surpresses the caching of the template results.
Before processing a page.tml page, the server loads any file named ".tml" (no prefix) in the same directory. This allows you to put procedure and variable definitions in the ".tml" file that are shared among the pages in that directory.
The server looks up the directory hierarchy to the document root for additional ".tml" files. These are all loaded in order from the root down towards the directory containing the template file page.tml. If you look at the sample htdocs tree that comes with the server, you can see how these .tml files are used.
|Home||Status||Learn||CGI Tests||Templates||Access Control||Reference Manual|