A typical leaf template begins with a call to startleafpage. This creates the target file, and sets up the "page" global variable.
Leaf templates use the TCL puts command to insert text into the target page. TCL variable and procedure substitutions occur whereever unescaped $ and [] symbols are found. The following fragment from a leaf template generates a header for a page. Note the $itemTitle variable substitution and the nested calls to the mchk2list and join procedures:
puts $page " <html> <head> <title>$itemTitle</title> <meta name=\"templateType\" content=\"$templateType\"> <meta name=\"family\" content=\"[join [mchk2list $family] ,]\"> <meta name=\"gameTitle\" content=\"$gameTitle\"> <meta name=\"prodType\" contents=\"$prodType\"> <meta name=\"Tech_Support_Type\" contents=\"$Tech_Support_Type\"> <meta name=\"specialOffer\" contents=\"$specialOffer\"> <meta name=\"serialNumber\" contents=\"$serialNumber\"> </head> "Note that each field defined in the database may be accessed by referring to a TCL variable with exactly the same name.
A leaf template should call endleafpage after all output to the target page has been generated.
A leaf template should call register once for each index page instance it wishes to appear on.