Templates

Templates (sometimes called parameterized templates) are used in two ways:

By placing parameters into a file, the file becomes a parameterized template; when it is opened "as a template" or inserted into a document, these parameters are replaced by the Code Interpreter, and failing that, in a the parameter dialog. This is further detailed in Token Expansion.

Default File Names

When a new document is opened based on a template, template parameters can be used as the basis for suggesting the file name when the document is first saved. The file suggested file extension is always that of the template, however.

This is controlled with the "Parameters used for file names" setting in the "Token expansion" setting group - there is a list of semicolon-separated parameter names, or any expression that the built-in code interpreter can evaluate, which is processed as the user or the code interpreter fill in the values. The first parameter name or expression that matches is then used as the default file name when the file is saved - locally or on an FTP server.

For example, to save an HTML page with the current date stamp as the file name, create a template like this:

<!-- $System.DateTime.Now.ToString("yyyyMMdd")% -->
<html>
    <!-- ... -->
</html>

Then, add the expression (without the dollar or percent signs) to the list in the "Parameters used for file names" setting, separated by a semicolon:

System.DateTime.Now.ToString("yyyyMMdd");Class;ClassName

Now, whenever you create a new document based on that template and save it, a file name like "20050415.htm" will be suggested.


See Also: Editor Basics | Token Lists | AutoText | Token Expansion