Using Templates

Templates are shortcuts used to insert a pre-defined framework of code into your scripts. The purpose is to save time and reduce the potential for errors in standard, repetitive code units. Once a template is inserted, you can complete the code quickly using manual and automated code entry methods.



A template must be defined in the Templates list in the Template Preferences page, accessed from Windows | Preferences | Templates, before it can be used. To learn how to create a new template from the Templates Preferences page, see Adding a New Template.

Templates are context sensitive and can be used in HTML, PHP, PHPDOC, JavaScript or CSS. The context of the current code being entered defines which templates are available. For example, PHP templates are not available if your current code is Java.

Inserting a Template into Code

This procedure describes how to insert a template into your script.

Instructions on how to complete a procedure

To insert a template:

  1. Place your cursor at the desired insertion point.

  2. Enter a character string (e.g. "Sw").

  3. Click Ctrl+Space.
    The Content Assist box will appear, listing all available templates and completion options that begin with that combination of keys.
    Templates are marked in the content assist list with a blue square. template_icon.png

  4. Double-click the required template from the list.
    The template will be entered into your code.






Entering "sw" and selecting the  "switch statement" template from the list will give you the following code:




Templates can be created, imported and exported through the Template Preferences page, accessed from Window | Preferences | PHP | Templates.


Related Links:
Templates Preferences

Using Content Assist