The template tool is one of several tools that help you perform certain tasks quickly and easily. The template tool is capable of saving a web developer from spending a tremendous amount of time making the same changes to many documents. For example, using the template tool, a header or footer can be changed on hundreds of documents in just minutes (or seconds) without the need for any scripting like ASP or PHP. This tool is even included in the lite edition.

One of the best ways to learn how to use the template tool is by example. This page contains some examples on using the template tool that is included with CSS HTML Validator.


hmtoggle_plus1Example 1 (basic example)
hmtoggle_plus1Example 2
hmtoggle_plus1Example 3 (inserting the current date)

Special Notes

1.<!-- TEMPLATESTART must appear by itself on a single line with no leading space and in all uppercase characters. Similarly, <!-- TEMPLATEEND --> must do the same. You can have multiple template files specified in a document, one for each <!-- TEMPLATESTART and <!-- TEMPLATEEND -->, but attempting to call a template file from another template file will be ignored (not be processed) unless the actual template file is the file being processed by the tool. That is, you cannot nest template files within template files and process the nested template files at the same time as its parent is processed.

2.The symbol names are case-sensitive and consist of alphabetic characters (uppercase or lowercase) or numerical digits and must appear one per line with their values. The exception to this is a blank line. For readability, you can insert blank lines between the lines that define symbols. There is no limit on the number of symbols that you can define.

3.There is a 'hidden' option to make the symbol names case-insensitive. Please note that It is not recommended that this option be used. If this option is enabled, then all symbol names are converted to uppercase before processing. To enable this hidden option 1) exit any running instance of CSS HTML Validator, 2) use the registry editor to OR the value 0x10000 with the value of Flags40 in HKEY_CURRENT_USER\Software\AI Internet Solutions\CSE HTML Validator v4\Validator DLL\Tools, and 3) restart CSS HTML Validator. (New v12.0029)

4.The mandatory TEMPLATE symbol must be all uppercase and must specify the location of the template file.

5.The symbol values begin immediately after the equals sign and end at the end of the line.

6.When a file is processed, all text between --> and <!-- TEMPLATEEND --> is thrown away and replaced with text from the template file. This is so that when you process a document with the template tool, the results of the last template tool processing is thrown away automatically and replaced with new results.

7.The original file is renamed with a .bak extension. If this tool fails, the original file is completely unaltered from the failed processing, and an error message should appear indicating the error.

8.By using the command line option for this tool (-t), you can process many documents quickly. For example, if you make the tool accessibly from a pull-down menu when you right-click on an HTML document, then you can select many HTML documents in File Explorer (previously known as Windows Explorer) and process all of them at one time. However, if you have the professional edition, then it is probably best to use the Batch Wizard.

Built-In Symbols

The template tool now has built-in symbols.

CURRENTTIME for the current time

CURRENTDATE for the current date

CURRENTDATE2 for the current date but with all non-ASCII characters converted to character references (New v16.0301)

CURRENTFILE for the current HTML document filename (not the template filename)

CURRENTYEAR for the current 4-digit year (New v10.0101)

VALIDATORVERSION for the current version of CSS HTML Validator (such as "6.00", without the quotes)

To change the format of the time string, specify a symbol named TIMEFORMAT that contains a format picture string.

To change the format of the date string, specify a symbol named DATEFORMAT that contains a format picture string.

If format picture strings are not given, then defaults are used. The default time and date formats can be changed in the 'Tools' page of the Validator Engine Options.


You can define a symbol in the following format:


Currently, the only supported function is FileContents(). By using this function, you can assign the contents of a file to a symbol name. For example:


This will cause $"DATAFILE" to be replaced by the contents of the file c:\data\january.txt when it appears in a template file.

You can also use the + operator to combine the contents of one or more files. For example:

DATAFILE:=FileContents("c:\\data\\january.txt") + FileContents("c:\\data\\february.txt")

Strings can also be used. For example:

DATAFILE:="The january file is:\n"+FileContents("c:\\data\\january.txt") + "\nEnd of file."

Please note that the above examples should be on one line. If any of them are on more than one line, then it has been wrapped.

NOTE: The '\' character is an escape character, so two of these characters are needed to specify a '\' character in a string (such as in the filenames above). '\n' is the escape sequence for a new line.