Creating Templates

Creating Templates

Creating templates is very much like writing code. To create a new code template, complete the following steps:

1.Create the template source files.

2.Insert substitution parameters into the template files.

3.Use the Template Manager to create a new template.

4.Add the template files to the newly-defined template.

Create the Template Source Files

This is the same process as writing any source file. Use SlickEdit® Core to write a file from scratch or to modify an existing file. Make sure your file is syntactically correct to minimize compile errors after it is in- stantiated.

In many languages, the $name$ syntax used by Code Templates is legal for identifiers, so you will be able to compile and run your template source files prior to instantiating them. In other languages, you will have to use temporary identifier names while writing the templates, and then put in the substitution para- meters once you are sure the source is correct.

You can store these source files in any directory and copy them to the templates directory during Step 4.

Insert Substitution Parameters into the Template Files

Use substitution parameters for any part of the source code that can differ from instantiation to instanti- ation. This includes class names, author names (if several people are sharing the same template files), or creation dates.

In our sample, we put in a substitution for copyright statement. See Substitution Parameters for more de-

105

Page 127
Image 127
Slick V3.3 Creating Templates, Create the Template Source Files, Insert Substitution Parameters into the Template Files