Templates are files that contain the basic structure for new files.
For example, a Perl template for a specific project might contain the
standard "#!" line, appropriate copyright statements, and
use statements calling a standard set of modules.
Komodo includes templates for a number of languages languages, and
lets you create and use your own. Templates can contain Interpolation
Shortcuts or Tab
Stops. They can be stored in a project or in the Toolbox for quick
access, and shared via the Common Data
Directory.
|
|
The New File menu option, invoked via
File|New|New File, or via the associated
key binding,
provides access to numerous templates for creating
new files. These templates consist of standard code that is generally included
in programs of the selected type. For example, the Perl template creates a
file with a ".pl " extension that contains the line
"use strict; "; the XSLT stylesheet template creates a file with an
".xsl " extension and an xml version and xsl stylesheet declaration.
To create a new file from a template file, in the New File
dialog box, select the category in the Left Pane, then double-click the template
name in the Right Pane. A new file is created in the Komodo editor using the
code stored in the template.
When using the New File button on the Standard Toolbar,
the template (if any) associated with the language in the
new files preferences is used
to create the new file.
Alternatively, templates can be stored in a
project or the
Toolbox, and can be associated with a
key binding.
Custom templates are created in the Komodo editor; on saving the file,
it is identified as a template.
- Create Template File: In Komodo, create a file with the
desired contents for the template.
- Save as Template: Select File|Save As
Template.
Custom templates are stored in the "My Templates" folder (as displayed
in the Save File dialog box). Due to a Komodo bug (41829), OS X users must
navigate manually to:
<User-home-directory>/Library/Application Support/Komodo/3.x/templates/My Templates
Optionally, create shortcuts (on Windows), aliases (Mac OS X) or symlinks (on
Linux or Mac OS X) in the "My Templates" directory structure that point to files
located elsewhere on the system. Files should have an extension that allows
Komodo to correctly detect the language (according to the settings configured in
Komodo's File Associations
preference).
If you create a directory alongside My Templates with the same
name as a template group that already exists in Komodo (such as
Common or Web ), the contents of the two directories
are merged. If files of the same name exist in both directories, the file
in the directory at the same level as My Templates is used.
For example:
templates\
My Templates\ <--directory
MyCGI.pl <--file in the My Templates directory
TestSystem.tcl <--file in the My Templates directory
Corporate <--shortcut/symlink to corporate templates
Common\ <--directory
Python.py <--file; takes precedence over the Python.py template
MyCGI.pl <--file; displays in the Common folder
To edit an existing template, select File|Open|Template File.
The directory containing the My Templates directory (and any
"merge" directories, as described above) is displayed. Select the desired
template and make the desired changes.
Interpolation shortcuts
can be used in templates. When a new file is generated from a template file
containing interpolation shortcuts, the shortcut is converted to its relevant
value.
For example, if a template file contains the interpolation shortcut
[[%date:%d/%m/%Y %H:%M:%S]] , when a new file is created from
that template, the interpolation shortcut is converted to the current
date and time in the following format: 27/06/2004 11:10:21 .
Interpolation shortcuts within templates use the
bracketed syntax.
Refer to the interpolation shortcut
section for a complete description of the code, syntax and usage.
Use the Komodo Project Manager or
the Toolbox to store frequently used
templates. In addition to the general methods described in
Adding Components to
Projects and
Adding Components to the
Toolbox, templates can be added to the Toolbox via the New File
dialog box. Select Add to Toolbox to add the selected
template to the Toolbox.
Right-click a template to access the following options:
- Open Template: Use this option to create a new file
from the selected template.
- Cut/Copy/Paste: These options are used to remove the
template from a project or the Toolbox, or to move templates between the
project and the Toolbox (and vice versa).
- Export as Project File: When this option is invoked,
a new project file is created that contains the template from which the
option is invoked. You are prompted to provide the name of the new project
file and the directory where it will be stored. To open the new project
file, select File|Open|Project.
- Export Package: Templates can be archived and
distributed among multiple Komodo users via "packages". Packages are
compressed archive files that contain the template from which the
Export Package option was invoked. Packages are stored in
files with a ".kpz" extension, and can be opened by any
archiving utility that supports
libz (for example WinZip).
The Export
Package option differs from the Export as Project
File option in that copies of filesystem-based components (such as
files and dialog projects) are included in the archive. Conversely,
Export as Project File creates a project with a reference to
the component's original location and does not create copies of the components.
When Export Package is invoked, you are prompted for a name
and file location for the package. Exported packages can
only be imported into "container" objects in Komodo, such as projects, the
Toolbox, and folders within projects and the Toolbox. See
Toolbox - Exporting and
Importing Toolbox Contents,
Projects - Importing
and Exporting Projects via Packages, or
Folders - Import Contents from
Package for more information.
- Rename: To change the name of a template (as displayed
in the Project Manager or Toolbox), select this option and enter a new name.
- Delete: To remove a template from a project or the
Toolbox, select this option. The reference to the template is deleted;
the file containing the template is not deleted.
- Properties: Changes the title
or the disk location of the template. In addition, the icon and key binding
assigned to the template are accessed via the Properties
dialog box. See below for instructions on altering the template's
icon or key binding.
The default template icon can be replaced with custom icons. Komodo
includes more than 600 icons; alternatively, select a custom image
stored on a local or network drive (use 16x16-pixel images for best results).
To assign a custom icon to a template:
- On the Projects or Toolbox tab,
right-click the desired template and select Properties.
Alternatively, click the template in the Projects or
Toolbox tab, then select
Projects|template_name|Properties or
Toolbox|template_name|Properties.
- In the Properties dialog box, click Change Icon.
- In the Pick an Icon dialog box, select a new icon and click
OK. Alternatively, click Choose Other,
and browse to the desired image file.
- In the Properties dialog box for the template, click OK.
The custom icon is displayed next to the template.
To revert to the default icon for a selected template:
- On the Projects or Toolbox tab,
right-click the desired template and select Properties.
- Click Reset, then click OK. The default
icon is displayed next to the template.
Custom key bindings can be assigned to templates stored in the
Toolbox or in a
Project. Use the
Key Binding tab in the template's Properties to specify the
keystrokes that invoke the template. See
Key Bindings
for Custom Components for more information.
|