Creating Code Templates

From FDT Documentation

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
-
FDT’s code templates, also refereed to as code snippets,  allow for quick generation of user defined code. Although FDT ships with many templates pre-installed, users can edit existing templates, create new ones and even share templates with other FDT developers. Similar to Advanced Code Completion, code templates are activated by typing part or all of the template's name and use the keystroke Ctrl+Space (OSX) or Alt+Space (WIndows). [http://fdt.powerflasher.com/docs/File:05_001.jpg Template in action].
+
FDT’s code templates, also refereed to as code snippets,  allow for quick generation of user defined code. Although FDT ships with many templates pre-installed, users can edit existing templates, create new ones and even share templates with other FDT developers. Similar to Advanced Code Completion, code templates are activated by typing part or all of the template's name and use the keystroke '''Ctrl+Space''' (OSX) or '''Ctrl+Space''' (Windows). [http://fdt.powerflasher.com/docs/File:05_001.jpg].
= Opening The Templates Editor =
= Opening The Templates Editor =
-
To access FDT’s templates, open FDT’s Preferences window and navigate to FDT>Editor>Templates [http://fdt.powerflasher.com/docs/File:05_002.jpg].   
+
To access FDT’s templates, open FDT’s Preferences window and navigate to ''FDT>Editor>Templates'' [http://fdt.powerflasher.com/docs/File:05_002.jpg].   
= Creating Templates =
= Creating Templates =
-
With the Templates window open, click the New... button to begin creating your own template [http://fdt.powerflasher.com/docs/File:05_003.jpg]. With the New Template window open we see various fields to fill in:
+
With the Templates window open, click the '''New...''' button to begin creating your own template [http://fdt.powerflasher.com/docs/File:05_003.jpg]. With the New Template window open we see various fields to fill in:
-
Name -The name of the template that will be searched when code completion is activated [http://fdt.powerflasher.com/docs/File:05_004.jpg].
+
*'''Name''' -The name of the template that will be searched when code completion is activated [http://fdt.powerflasher.com/docs/File:05_004.jpg].
-
Context - The language context that the template will be active within while editing a file in the Editor View [http://fdt.powerflasher.com/docs/File:05_005.jpg].
+
*'''Context''' - The language context that the template will be active within while editing a file in the Editor View [http://fdt.powerflasher.com/docs/File:05_005.jpg].
-
Description - A description of the template. This appears both within the content assist pop up window and within the New Templates window [http://fdt.powerflasher.com/docs/File:05_006.jpg].
+
*'''Description''' - A description of the template. This appears both within the content assist pop up window and within the New Templates window [http://fdt.powerflasher.com/docs/File:05_006.jpg].
-
Pattern - The text that will inserted when a user selects the template via the pop up window [http://fdt.powerflasher.com/docs/File:05_007.jpg].
+
*'''Pattern''' - The text that will inserted when a user selects the template via the pop up window [http://fdt.powerflasher.com/docs/File:05_007.jpg].
After setting the Name, Context and Description, fill in what text you wish to be inserted into your file when this template is selected [http://fdt.powerflasher.com/docs/File:05_008.jpg]. To enhance the functionality of templates users can add variables to their templates. Variables allow for more powerful and flexible templates by analyzing the context of the template when activated and adding text based on that context. FDT ships with a number of pre-defined variables which can be accessed by clicking the 'Insert Variable...' button [http://fdt.powerflasher.com/docs/File:05_009.jpg].  Users can add their own their variables by using the syntax ‘${}’ and adding your own description between the braces [http://fdt.powerflasher.com/docs/File:05_010.jpg].
After setting the Name, Context and Description, fill in what text you wish to be inserted into your file when this template is selected [http://fdt.powerflasher.com/docs/File:05_008.jpg]. To enhance the functionality of templates users can add variables to their templates. Variables allow for more powerful and flexible templates by analyzing the context of the template when activated and adding text based on that context. FDT ships with a number of pre-defined variables which can be accessed by clicking the 'Insert Variable...' button [http://fdt.powerflasher.com/docs/File:05_009.jpg].  Users can add their own their variables by using the syntax ‘${}’ and adding your own description between the braces [http://fdt.powerflasher.com/docs/File:05_010.jpg].

Revision as of 22:02, 27 September 2010

FDT’s code templates, also refereed to as code snippets, allow for quick generation of user defined code. Although FDT ships with many templates pre-installed, users can edit existing templates, create new ones and even share templates with other FDT developers. Similar to Advanced Code Completion, code templates are activated by typing part or all of the template's name and use the keystroke Ctrl+Space (OSX) or Ctrl+Space (Windows). [1].

Contents

Opening The Templates Editor

To access FDT’s templates, open FDT’s Preferences window and navigate to FDT>Editor>Templates [2].

Creating Templates

With the Templates window open, click the New... button to begin creating your own template [3]. With the New Template window open we see various fields to fill in:

  • Name -The name of the template that will be searched when code completion is activated [4].
  • Context - The language context that the template will be active within while editing a file in the Editor View [5].
  • Description - A description of the template. This appears both within the content assist pop up window and within the New Templates window [6].
  • Pattern - The text that will inserted when a user selects the template via the pop up window [7].

After setting the Name, Context and Description, fill in what text you wish to be inserted into your file when this template is selected [8]. To enhance the functionality of templates users can add variables to their templates. Variables allow for more powerful and flexible templates by analyzing the context of the template when activated and adding text based on that context. FDT ships with a number of pre-defined variables which can be accessed by clicking the 'Insert Variable...' button [9]. Users can add their own their variables by using the syntax ‘${}’ and adding your own description between the braces [10].

Tip - When multiple instances of a custom variable exist, all instances of that variable will be simultaneously be updated.

Editing Existing Templates

With the Templates window open, choose a template to edit and click the 'Edit...' [11]. The Edit Template window will open [12] and you can begin to edit the selected template [13]. When finished, click OK to save the template.

Importing and Exporting ( Sharing ) Templates

Templates can be easily shared and even versioned via CVS. FDT templates are distributed via XML which FDT creates upon exporting. Upon importing, will interpret the XML and add the templates to the Templates Editor.

Exporting Templates

With the Templates window open highlight the templates you wish to export, it can be just one or all of them. With your chosen templates selected, click the Export... button [14]. FDT will then convert the templates to XML and then ask you where you would like to save the generated XML [15].

Importing Templates

With the Templates window open click the 'Import...' button [16]. FDT will then ask you to select the file which contains the templates you wish to add to your existing list of templates. Navigate to a valid .XML file and then click 'Open' [17]. If the provided template file is valid, FDT will add the templates to the available templates. If the templates valid is invaild, e.g. an error in the .XML syntax, FDT will notify with an error message [18].

Get FDT5