10.02.2013 Views

SlickEdit User Guide

SlickEdit User Guide

SlickEdit User Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CODE TEMPLATES<br />

[ConfigDir]/templates/ItemTemplates/<br />

TIP You can locate your Configuration Directory from the main menu by clicking Help > About<br />

<strong>SlickEdit</strong>.<br />

All files will be created relative to the folder you choose. For more information about how templates<br />

are organized, see Organizing Templates.<br />

2. Create or edit a code file (e.g. *.cpp, *.java, etc.). Replace occurrences of substitutable text with<br />

substitution parameter names. For example, you might want to make the name of a C++ or Java<br />

class into a substitution parameter, in which case you could use the $safeitemname$ substitution<br />

parameter. For more information on substitution parameters, see Substitution Parameters.<br />

3. Create an XML file and give it an extension of .setemplate.<br />

4. Insert template metadata into the .setemplate file. See the example below. For more information<br />

on template metadata elements, see Code Template Metadata File Reference.<br />

5. Create a new project or open an existing one.<br />

6. From the main menu, click Project > Add New Item.<br />

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

Example<br />

The following example illustrates the metadata for an item template for a custom Java class, along with the<br />

content of the Java source code file.<br />

From the Add New Item dialog box, if the user entered Foo.java for the item name, then $fileinputname$<br />

would be replaced with “Foo” in the file name of the file created, and $safeitemname$ would be replaced<br />

with “Foo” in the Java source code file.<br />

MyClass.setemplate:<br />

<br />

<br />

<br />

<br />

My Java Class<br />

My custom Java class<br />

MyClass.java<br />

<br />

<br />

<br />

MyClass.java<br />

<br />

<br />

<br />

MyClass.java:<br />

class $safeitemname$ {<br />

};<br />

Creating a Multi-file Template<br />

A multi-file template is a template item that creates more than one file.<br />

248 <strong>SlickEdit</strong>® <strong>User</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!