Code Templates

Code templates are pre-defined units of code that you can use to automate the creation of common code elements, like a standard class implementation or design patterns. You can create templates for a whole file or multiple files. Templates can contain substitution parameters that are replaced when the template is instantiated when a new element is created from that template. Some parameters are replaced with calculated or pre-defined values, like date or author. If a value is not known, you will be prompted for a value when the template is instantiated.

Note

Code Templates are for creating new files. To insert code into an existing file, use SlickEdit Core Aliases.

Code templates are composed of one or more template source files and a metadata file providing additional information, like the name of the template, a description of the template, prompts for substitution parameters, and default values for substitution parameters. The following is an example of a single file source template. The items surrounded by dollar signs, "$", are the substitution parameters.

/*
 * $copyright$
 */
package $package$;
/**
 * @author $author$
 * @version $version$
 */
public class $safeitemname$ {
     /**
     * Default constructor.
     */
    public $safeitemname$(){
    }
}

Templates can be organized into Categories to make them easier to manage. The templates shipped with SlickEdit® Core are listed under Installed Templates and are organized into categories by language and then by purpose. The Template Manager dialog will not allow you to add, edit, or delete Installed Templates. Use the Template Manager dialog to add, edit, and delete templates under User Templates. The Template Manager dialog is accessed by clicking File → SlickEdit Template Manager.

Instantiating a Template

You can add an item to your current project by clicking File → Add New Item from SlickEdit Template. If you want to create a new item from a template without adding it to your current project, then click File → New Item from SlickEdit Template. The Add New Item dialog box is shown below.

We call the process of creating new files from a template "instantiating a template". When a template is instantiated, you are prompted for the name of the new item. This name is often used heavily in the template. For a class template, the name will likely be the class name or a part of the class name. In the sample template, $safeitemname$ is a form of this name that strips out any spaces, making it safe to use as part of an identifier. This value can even be used as part of the file name when the template is instantiated.

If any of the values in the template are not known at instantiation time, the Parameter Entry dialog box, shown below, will prompt you for values.

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 instantiated.

In many languages, the $name$ syntax used by SlickEdit Core 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 parameters 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 instantiation. 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 details.

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 Code Template Manager dialog and click the Plus (+) button to add the files you created 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 different character to use as the delimiter. Click File → SlickEdit Template Manager and click on the Custom 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, directories, 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 templates that fill in a header comment with the author's (your) name. You would only have to define the substitution parameter once. To define these parameters, open the Template Manager and select the Custom Parameters tab.

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

Predefined Substitution Parameters

The following substitution parameter names and values are pre-defined for use in an item template. The default delimiter "$" is used:

Parameter Name

Description

$itemname$

Name of item entered, as on the Add New Item dialog.

$fileinputname$

Name of item entered, as on the Add New Item dialog, without file extension.

$safeitemname$

Name of item entered, as on the Add New Item dialog, with all unsafe characters replaced with safe characters. For example, if the item name was My Custom Class, then the $safeitemname$ would evaluate to My_Custom_Class for a C++ source code file.

$upcasesafeitemname$

Same as $safeitemname$ with all characters uppercased.

$lowcasesafeitemname$

Same as $safeitemname$ with all characters lowercased.

$tempdir$

Location of operating system temp directory. No trailing file separator.

$rootnamespace$

Root namespace or package for the current project. This is typically used for C# and Java projects to find the namespace containing Main() (or main() in the case of Java).

$ampmtime$

Time of day in the form hh:mm[am|pm]. Example: 11:34pm

$localtime$

Time of day in locale-specific format.

$time$

Time of day in the form hh:mm:ss.

$localdate$

Current date in locale-specific format.

$date$

Current date in the form mm/dd/yyyy.

$projectname$

Current project name (no path, no extension).

$safeprojectname$

Current project name (no path, no extension), with all unsafe characters replaced with safe characters. For example, if the project name was: My Project.vpj, then $safeprojectname$ would evaluate to My_Project for a C++ source code file.

$workspacename$

Current workspace name (no path, no extension).

$safeworkspacename$

Current workspace name (no path, no extension), with all unsafe characters replaced with safe characters. For example, if the workspace name was: My Workspace.vpw, then $safeworkspacename$ would evaluate to My_Workspace for a C++ source code file.

$projectworkingdir$

Current project working directory. No trailing file separator.

$projectbuilddir$

Current project build (output) directory. No trailing file separator.

$projectconfigname$

Current project configuration name.

$workspaceconfigname$

Current workspace configuration name. This will be the same as $projectconfigname$ except for MS Visual Studio workspace which will have a separate workspace/solution configuration name.

$projectdir$

Location of current project file. No trailing file separator.

$workspacedir$

Location of current workspace file. No trailing file separator.

$username$

Operating system login name.

Organizing Templates

Templates are organized into category hierarchies as shown on the Add New Item dialog. These category hierarchies map exactly to the directory structure under the locations for installed and user templates.

To create a new template item category:

  1. Create a new folder under the user templates directory. For example, if you wanted to create a Dialogs category for Java project items, you would create the following directory:

    [ConfigDir]/templates/ItemTemplates/Java/Dialogs/
  2. Place all templates for the category under this directory.

  3. Create a new project or open an existing one.

  4. From the main menu click File → New Item from SlickEdit Template.

  5. Verify that your new category appears in the Categories list on the Add New Item dialog box.

Caution

The Template Manager dialog will not allow you to create new categories or re-organize categories under Installed Templates since the next patch or upgrade would overwrite any customizations you have made. If you want to customize an installed template, then we suggest you copy it to the User Templates directory and perform your customization on the copy. For information about the location of shipped templates, see Locating Templates.

Template Manager Operations

Use the Template Manager dialog to add, edit, and delete templates. You can show this dialog by clicking File → SlickEdit Template Manager. Use the Categories list to select a category. Selecting a category populates the Templates list with templates for that category.

Note

You can only add, edit, and delete templates under the User Templates node in the Template Manager dialog. If you want to modify a template shipped with SlickEdit Core, copy it to the ItemTemplate subdirectory in your config. See Locating Templates.

Creating a New Category

To create a new category under the selected category, right-click in the Categories tree and select New Category. You will be prompted for a category name. After clicking OK, you can add templates in the new category.

Creating a New Template

To create a new template, select the category in which to create the template, then right-click in the Templates list and select New Template. You will be prompted for a template name which is used to create the new template file. After clicking OK, you can edit the new template the lower half of the dialog.

Editing an Existing Template

To edit an existing template, select a template from the Templates list, and edit its properties in the lower half of the dialog.

Deleting a Template

To delete a template, select the template you want to delete from the Templates list, right-click and select Delete Template from the context menu.

Template Manager Dialog

The Template Manager dialog is made up of the following elements:

  • Categories - Lists a hierarchy of item categories for installed and user template items.

Note

Installed templates can be viewed but not modified.

  • Templates - Lists the templates for the currently selected category. When you select a template, you are able to edit its properties in the lower half of the dialog.

  • Template file - File name of the currently selected template.

Details Tab

The Details tab of the Template Manager dialog contains the following:

  • Name - Specifies the name for the template item. The name is used in the Templates list of the Add New Item dialog.

  • Description - Specifies the description for the template item. The description is displayed on the Add New Item dialog when the template is selected.

  • Default name - Specifies the default item name when using the Add New Item dialog box.

  • Sort order - Specifies an order number that is used to sort the template item in relation to other template items in a list. Used to sort template items in a category on the Add New Item dialog box. Lower sort orders are placed ahead of higher sort order values in a sorted list.

Files Tab

Use the Files tab of the Template Manager dialog to add, edit, order, and delete files in a template. Files are created from a template when using the Add New Item dialog, as when adding an item template to a project.

Add, Edit, Order, and Delete operations are accessible from the buttons on the right side or from the context menu inside the list of files.

Custom Parameters Tab

Use the Custom Parameters tab of the Template Manager dialog to add, edit, and delete substitution parameters in a template. Substitution parameters are used to replace parameter names in the content of files created from a template with a pre-defined value. Substitution parameters can also be used to form target file names (Files tab).

Add, Edit, and Delete operations are accessible from the buttons on the right side or from the context menu inside the list of parameters.

Template Options Dialog

Use this dialog to edit options that are common to all templates. You can launch this dialog from the Template Manager dialog by clicking the Options button.

Global Substitution Parameters

The Global substitution parameters area on the Template Options dialog lists the substitution parameters that are common to all templates. A common substitution parameter, for example, could be "author" where the parameter value is your name. You could then create code templates that automatically fill in a header comment with the author's (your) name.

Add, Edit, and Delete operations are accessible from the buttons on the right side or from the context menu inside the list of parameters.

Add File Dialog

Used to add a file to a template. To launch this dialog, right-click on a file in the Files tab of the Template Manager dialog, and select Add File, or use the Add File button. The dialog contains the following:

  • Source file name - When a file is created from a template, as when adding an item template from the Add New Item dialog, it is created from the source file with this file name.

  • Copy source file to template directory - Check this option to place a copy of the file in the current template's directory and change the source file name to point to the new file in the template. The file is not copied until you click OK.

  • Target file name - When a file is created from a template, as when adding an item template from the Add New Item dialog, the file name of the file that is created on disk is formed from the target file name in the location you specify. Use the menu button to the right of this field to insert common pre-defined substitution parameters. For example, $fileinputname$ is the item name provided on the Add New Item dialog when adding an item template to your project.

  • Replace parameters in target file content - Check this option if you want substitution parameters embedded in the content of the target file to be replaced when the file is created from the template, as when adding an item template to your project from the Add New Item dialog.

  • Preview - Previews how the file would be copied when creating the file from a template as if the source file name and target file name were fully resolved.

Add Parameter Dialog

Used to add a custom substitution parameter to a template. This dialog is launched when performing an Add operation from the Custom Parameters tab of the Template Manager Dialog. When files are created from a template, as when adding an item template to your project from the Add New Item dialog box, you can configure your template to replace all substitution parameters with values. For a list of pre-defined substitution parameters, see Predefined Substitution Parameters.

The Add Parameter dialog contains the following:

  • Name - This is the name of the substitution parameter WITHOUT delimiters. For example, if the delimiter is "$" (the default), then a substitution parameter that inserts a copyright string would have a name of "copyright" and NOT "$copyright$". Do not use quotes in the name. Valid characters for a parameter name are: A-Za-z0-9_

  • Value - This is the value that the substitution parameter evaluates to when a string or file is created from the template and has its substitution parameters replaced with values.

  • Prompt for value - Check this option if you always want to be prompted for the value of a substitution parameter. When set, the Value field becomes a default value field and is used to pre-populate the value when you are prompted.

  • Prompt string - Specifies the prompt string to display when being prompted for a substitution parameter value.

Add New Item Dialog

Used to add an item to your current project, the Add New Item dialog is displayed when you click File → New Item from SlickEdit Template or File → New Item from SlickEdit Template.

Use the Categories list to select a category. Selecting a category populates the Templates list with template items for that category. You can then select an item from the Templates list, enter a unique Name for the item, and enter a Location. Click Add to instantiate the template with the name and location you provided.

You can manage your templates from the Template Manager dialog box by choosing File > Template Manager.

The Add New Item dialog contains the following:

  • Categories - Lists a hierarchy of item categories for installed and user template items.

  • Templates - Lists the template items for the currently selected category. When you select a template item, a brief description for that item is displayed just above the Name field.

  • Name - Enter the name of the file you want to create.

Note

For single file templates (templates that create a single file) this is the name of the file. Multi-file templates use the name of the item entered to form names of files in the template. For more information about creating multi-file templates, see Creating a Multi-file Template.

  • Location - Enter the location to which to save the item.

  • Add to current project - When selected, the new item is added to the current project.

  • Add - After you have selected a template item, provided a name and a location, click Add to instantiate the template item.

Locating Templates

Installed Templates

Templates that are installed with the product are located at:

[EclipseInstallDir]/plugins/com.slickedit.windows.libs_[VERSION]/slickedit/sysconfig/templates/ItemTemplates/

For example, the following directory under Windows contains item templates for the C++ language:

[My Documents]\My SlickEdit Core Config\[VERSION]\templates\ItemTemplates\C++

User Templates

User templates are templates that the user creates and are located at:

[ConfigDir]/templates/ItemTemplates/

Tip

You can locate your Configuration Directory from the main menu by clicking Help → About SlickEdit Core.

Manually Creating a Template

SlickEdit® Core Code Templates are represented as files stored in specific directories. A template is composed of the source file or files for the template and a metadata template file that provides additional information. Since these are just files, you can write them using SlickEdit Core.

To manually create an item template:

  1. Choose a category folder under the user templates directory. Your user templates directory is at:

    [ConfigDir]/templates/ItemTemplates/

    Tip

    You can locate your Configuration Directory from the main menu by clicking Help → About SlickEdit Core.

    All files will be created relative to the folder you choose. For more information about how templates are organized, see Organizing Templates.

  2. Create or edit a code file (e.g. *.cpp, *.java, etc.). Replace occurrences of substitutable text with substitution parameter names. For example, you might want to make the name of a C++ or Java class into a substitution parameter, in which case you could use the $safeitemname$ substitution parameter. For more information on substitution parameters, see Substitution Parameters.

  3. Create an XML file and give it an extension of .setemplate.

  4. Insert template metadata into the .setemplate file. See the example below. For more information on template metadata elements, see Code Template Metadata File Reference.

  5. Create a new project or open an existing one.

  6. From the main menu, click File → New Item from SlickEdit Template.

  7. Verify that your new template item appears in the Templates list on the Add New Item dialog box.

Example

The following example illustrates the metadata for an item template for a custom Java class, along with the content of the Java source code file.

From the Add New Item dialog box, if the user entered Foo.java for the item name, then $fileinputname$ would be replaced with "Foo" in the file name of the file created, and $safeitemname$ would be replaced with "Foo" in the Java source code file.

MyClass.setemplate:

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My Java Class</Name>
    <Description>My custom Java class</Description>
    <DefaultName>MyClass.java</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File TargetFilename="$fileinputname$.java">MyClass.java</File>
    </Files>
  </TemplateContent>
 
</SETemplate>

MyClass.java:

class $safeitemname$ {
};
Creating a Multi-file Template

A multi-file template is a template item that creates more than one file.

Multi-file templates require the use of substitution parameters to ensure that file name and extension parts are used when creating each file of the template item. For example, a C++ class typically consists of:

  • A .h file that contains the class definition.

  • A .cpp file that contains the class implementation.

Since you can only enter one name into the Name field on the Add New Item dialog box, you need a way to specify the target file name for each file created by the multi-file template. In the C++ class example below, the .h and .cpp files are created with the name you provide, while their extensions are preserved.

To create a multi-file item template from the Template Manager dialog, click File → SlickEdit Template Manager.

To manually create a multi-file item template:

  1. Create the item template the same way a single file template would be created. For more information on manually creating a template item, see Manually Creating a Template.

  2. Add TargetFilename attributes to each of the File elements in your template metadata file (.setemplate). Set the value of each TargetFilename attribute to $fileinputname$.[extension], where [extension] is the file extension of the target file name being created. When the files are created, their names will be based on the name you entered in the Name field of the Add New Item dialog box. See the example below.

Example

The following example demonstrates a multi-file item template .setemplate file. The item creates C++ class header (.h) and implementation (.cpp) files.

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My C++ Class</Name>
    <Description>My complete C++ class header and implementation</Description>
    <DefaultName>MyClass.cpp</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File TargetFilename="$fileinputname$.cpp">MyClass.cpp</File>
      <File TargetFilename="$fileinputname$.h">MyClass.h</File>
    </Files>
  </TemplateContent>
 
</SETemplate>

Code Template Metadata File Reference

Template metadata describes the template item, its files, and how to create the template. Template metadata files have a .setemplate extension.

The SETemplate element is the root element of a template file.

Summary of metadata elements:

Element

Child Elements

Attributes

Elements

-

-

Description

-

-

File

-

ReplaceParameters,TargetFilename

Files

File

-

Name

-

-

Parameter

-

Name,Value

Parameters

Parameter

-

SETemplate

TemplateContent,TemplateDetails

Type,Version

SortOrder

-

-

Template Content

Files,Parameters

Delimiter

TemplateDetails

DefaultName,Description,Name,SortOrder

-

Elements

DefaultName

DefaultName is an optional child element of TemplateDetails. Specifies the default item name when using the Add New Item dialog box. This element becomes more important in multi-file templates where you need to specify a DefaultName element in order to create file names from parts of the input item name. See the example below.

  • Attributes - None.

  • Child elements - None.

  • Parent elements - TemplateDetails.

  • Value - Text value is required. The text value specifies the default name of the template item. Used to populate the name field with an initial value on the Add New Item dialog box.

Example

The following example illustrates the metadata for an item template for a C++ class that creates a header file (.h) and implementation file (.cpp).

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My C++ Class</Name>
    <Description>My complete C++ class header and implementation</Description>
    <DefaultName>MyClass.cpp</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File TargetFilename="$fileinputname$.cpp">MyClass.cpp</File>
      <File TargetFilename="$fileinputname$.h">MyClass.h</File>
    </Files>
  </TemplateContent>
 
</SETemplate>
Description

Description is a required child element of TemplateDetails. Specifies the description for the template item. See the example below.

  • Attributes - None.

  • Child elements - None.

  • Parent elements - TemplateDetails.

  • Value - Text value is required. The text value specifies the description of the template item. The description is shown on the Add New Item dialog box.

Example

The following example illustrates the metadata for an item template for a custom Java class.

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My Java Class</Name>
    <Description>My custom Java class</Description>
    <DefaultName>MyClass.java</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File>MyClass.java</File>
    </Files>
  </TemplateContent>
 
</SETemplate>
File

File is an optional child element of Files. Specifies a file for the template item. See the example below.

  • Attributes

    Attribute

    Description

    ReplaceParameters

    Optional.

    Specifies whether parameter substitution takes place on the file contents when the file is created from the template. Note that parameter substitution always takes place on the TargetFilename attribute value (example:

    TargetFilename="$fileinputname$.cpp").

    Possible values are "1" (true) or "0" (false).

    Defaults to "1" (true).

    TargetFilename

    Optional.

    Specifies the actual name of the item that is created from the template.

    This attribute is especially useful when creating a multi-file template where file names of files created from the template are assembled by parameter substitution.

  • Child elements - None.

  • Parent elements - TemplateContent.

  • Value - Text value is required. Value is the path of a file in the template item.

Example

The following example illustrates the metadata for an item template for a C++ class that creates a header file (.h) and implementation file (.cpp).

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My C++ Class</Name>
    <Description>My complete C++ class header and implementation</Description>
    <DefaultName>MyClass.cpp</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File TargetFilename="$fileinputname$.cpp">MyClass.cpp</File>
      <File TargetFilename="$fileinputname$.h">MyClass.h</File>
    </Files>
  </TemplateContent>
 
</SETemplate>
Files

Files is a required child element of TemplateContent. Specifies files for the template item. See the example below.

  • Attributes - None.

  • Child elements - File.

  • Parent elements - TemplateContent.

  • Value - N/A

Example

The following example illustrates the metadata for an item template for a C++ class that creates a header file (.h) and implementation file (.cpp).

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My C++ Class</Name>
    <Description>My complete C++ class header and implementation</Description>
    <DefaultName>MyClass.cpp</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File TargetFilename="$fileinputname$.cpp">MyClass.cpp</File>
      <File TargetFilename="$fileinputname$.h">MyClass.h</File>
    </Files>
  </TemplateContent>
 
</SETemplate>
Name

Name is a required child element of TemplateDetails. Specifies the name for the template item. See the example below.

  • Attributes - None.

  • Child elements - None.

  • Parent elements - TemplateDetails.

  • Value - Text value is required. The text value specifies the name of the template item. The name is shown in the Templates list on the Add New Item dialog box.

Example

The following example illustrates the metadata for an item template for a custom Java class.

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My Java Class</Name>
    <Description>My custom Java class</Description>
    <DefaultName>MyClass.java</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File>MyClass.java</File>
    </Files>
  </TemplateContent>
 
</SETemplate>
Parameter

Parameter is an optional child element of Parameters. Specifies a custom substitution parameter for the template item. For a list of pre-defined substitution parameters, see Predefined Substitution Parameters.

See the example below.

  • Attributes

    Attribute

    Description

    Name

    Parameter name. This is the name of the substitution parameter WITHOUT delimiters. For example, if the delimiter is "$" (the default), then a substitution parameter that inserts a copyright string would be defined as "copyright" and NOT as

    "$copyright$".

    Value

    Parameter value. This is the value that the substitution parameter evaluates to when a string or File is created from the template.

  • Child elements - None.

  • Parent elements - Parameters.

  • Value - N/A

Example

The following example illustrates the metadata for an item template for a custom Java class.

When MyClass.java is used to create the file from the template, all occurrences of $copyright$ in the created file will be replaced with "(c)2005-2006".

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My Java Class</Name>
    <Description>My custom Java class</Description>
    <DefaultName>MyClass.java</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Parameters>
      <Parameter Name="copyright" Value="(c)2005-2006" />
    <Parameters>
    <Files>
      <File>MyClass.java</File>
    </Files>
  </TemplateContent>
 
</SETemplate>
Parameters

Parameters is a required child element of TemplateContent. Specifies custom substitution parameters for the template item. For a list of pre-defined substitution parameters, see Predefined Substitution Parameters.

See the example below.

  • Attributes - None.

  • Child elements - Parameter.

  • Parent elements - TemplateContent.

  • Value - N/A

Example

The following example illustrates the metadata for an item template for a custom Java class.

When MyClass.java is used to create the file from the template, all occurrences of $copyright$ in the created file will be replaced with "(c)2005-2006".

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My Java Class</Name>
    <Description>My custom Java class</Description>
    <DefaultName>MyClass.java</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Parameters>
      <Parameter Name="copyright" Value="(c)2005-2006" />
    <Parameters>
    <Files>
      <File>MyClass.java</File>
    </Files>
  </TemplateContent>
 
</SETemplate>
SETemplate

Root element. Contains all metadata about template item.

  • Attributes

    Attribute

    Description

    Version

    Template version number. The current version is "1.0".

    Type

    Template type. Valid types are: "Item".

  • Child elements - TemplateDetails, TemplateContent.

  • Parent elements - None.

  • Value - N/A

Example

The following example illustrates the metadata for an item template for a custom Java class.

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My Java Class</Name>
    <Description>My custom Java class</Description>
    <DefaultName>MyClass.java</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File>MyClass.java</File>
    </Files>
  </TemplateContent>
 
</SETemplate>
SortOrder

SortOrder is an optional child element of TemplateDetails. Specifies an order number that is used to sort the template item in relation to other template items in a list. Used to sort template items in a category on the Add New Item dialog box.

If no SortOrder is specified for a template item, then the SortOrder value defaults to "0".

  • Attributes - None.

  • Child elements - None.

  • Parent elements - TemplateDetails.

  • Value - Text value is required. An integer that is greater than or equal to "0". When sorting in relation to other template items, low SortOrder values are placed ahead of higher values in a sorted list.

Example

The following example illustrates the metadata for an item template for a custom Java class.

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My Java Class</Name>
    <Description>My custom Java class</Description>
    <DefaultName>MyClass.java</DefaultName>
    <SortOrder>100</SortOrder>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File>MyClass.java</File>
    </Files>
  </TemplateContent>
 
</SETemplate>
TemplateContent

TemplateContent is a required child element of SETemplate. Specifies the contents of a template item.

  • Attributes

    Attribute

    Description

    Delimiter

    Optional.

    Delimiter used when replacing substitution parameters in content.

    Defaults to "$".

  • Child elements - Files, Parameters.

  • Parent elements - SETemplate.

  • Value - N/A

Example

The following example illustrates the metadata for an item template for a custom Java class.

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My Java Class</Name>
    <Description>My custom Java class</Description>
    <DefaultName>MyClass.java</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File>MyClass.java</File>
    </Files>
  </TemplateContent>
 
</SETemplate>
TemplateDetails

TemplateDetails is a required child element of SETemplate. Describes the template item. Details are used to display the template item on the Add New Item dialog box.

  • Attributes - None.

  • Child elements - DefaultName, Description, Name, SortOrder.

  • Parent elements - SETemplate.

  • Value - N/A

Example

The following example illustrates the metadata for an item template for a custom Java class.

<?xml version="1.0" ?>
<!DOCTYPE SETemplate SYSTEM "http://www.slickedit.com/dtd/vse/setemplate/1.0/setemplate.dtd">
<SETemplate Version="1.0" Type="Item">
 
  <TemplateDetails>
    <Name>My Java Class</Name>
    <Description>My custom Java class</Description>
    <DefaultName>MyClass.java</DefaultName>
  </TemplateDetails>
  <TemplateContent>
    <Files>
      <File>MyClass.java</File>
    </Files>
  </TemplateContent>
 
</SETemplate>