Creating a Source Code Template

Perform the following steps to add a new code template:

  1. Select Window > Preferences > Atelier > Templates on the main menu or click this link to open the Opens the Atelier Templates page Templates page.
  2. Click New... to open the template editor.
  3. Enter a name for the template in the Name field.
  4. Select the Context from the drop-down list. The context determines whether you can add the template to a class or to a routine.
  5. Either leave the Automatically insert check box selected, or unselect it. When it is selected, which is the default value, the editor inserts the template automatically if it is the only available option.
  6. Enter a description of the template in the Description field.
  7. The Pattern field is where you enter the code that makes up the template. You can add pre-defined template variables by clicking the Insert Variable... button, which opens a list of variable names and descriptions. These variables are evaluated by the editor when the template is used, and the corresponding information is added to the file. A particularly useful variable is cursor (${cursor}) which sets the location of the cursor when the user has finished editing other template variables.

    You can also add your own variables, which provide placeholders where the user can add information to the template structure. For example, the template classref, which adds a class reference, uses the two variables, ${className} and ${memberName}. When the user adds the classref template, the cursor is positioned on the ${className} variable. The user enters the name of a class, then tabs to ${memberName} and enters the name of a class member. Variables have the format ${variablename}.

You can edit an existing template by selecting the template and clicking Edit....

Related concepts

Source Code Templates

Related reference

Templates