Substitution Parameters

tails.

Use the Template Manager to Create a New Template

Click File SlickEdit Template Manager to bring up the Template Manager. Select the User Template folder in the tree, and right-click in either the Categories pane or the Templates pane to create a new template.

There are different operations based on whether you want to create a new category or not. You will be prompted for the name of the new template. Fill in a name and click OK. Now you can use the Template Manager to enter a description, add files, or set values for Custom Parameters.

Add the Template Files to the Newly-Defined Template

Select the Files tab on the Template Manager dialog and click the Plus (+) button to add the files you cre- ated in Step 1 to this template. You will have the option to link to the source in its current location or copy it to the template directory. You will also be prompted for a target file name. If you want the name of the instantiated template to appear in the file name, you should use a substitution variable in the name, like My$safeitemname$Class.java.

Substitution Parameters

Substitution parameters provide the real power in Code Templates. Without them, you would simply be making copies of static files. You can use substitution parameters to replace any text in the template's source code. You can also use substitution parameters in file names, which is useful in Java where a class must be defined in a file by the same name.

Substitution parameters are written as identifiers surrounded by a delimiter. The default delimiter is $. Use a double delimiter to represent the delimiter character in a template source file, $$. You can specify a dif- ferent character to use as the delimiter. Click File SlickEdit Template Manager and click on the Cus- tom Parameters tab to change the value for the Delimiter field.

We provide a set of predefined substitution parameters for items related to item name, project name, dir- ectories, date, and time. We can determine the value for these items rather than having to prompt for them. See the list at the end of this section for all the predefined substitution parameters.

You can define substitution parameters that are common to all templates. For example, you might want to define an "author" parameter where the parameter value is your name. You could then create code tem- plates that fill in a header comment with the author's (your) name. You would only have to define the sub- stitution parameter once. To define these parameters, open the Template Manager and select the Cus- tom Parameters tab.

If no value is provided for a substitution parameter, you will be prompted for one when the template is in- stantiated. This is useful for things like class name or other values that are different each time the tem- plate is instantiated.

Predefined Substitution Parameters

The following substitution parameter names and values are pre-defined for use in an item template. The

106

Page 128
Image 128
Slick V3.3 manual Use the Template Manager to Create a New Template, Predefined Substitution Parameters