Feature Showcase
Templates are files that contain the basic structure for new
files or projects. For example,
a Perl template 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 Tabstops. 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.
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.
Just as template files contain the basic structure for new files, project templates provide a basic framework for new projects.
To create a new project from a project template, click File|New|New Project from Template and choose from one of the available templates.
To save any project as a template select the project and click Project|Create Template From Project..., or right-click on the project and click Create Template From Project.... in the context-menu. The project will be exported as a project package and saved in the project-templates/My Templates sub-directory of the user data directory. Once the project has been saved as a template, it becomes available via File|New|New Project from Template.
Komodo ships with project templates for, Ruby on Rails, Komodo Extensions, and Firefox Extensions.
Use the Komodo Projects sidebar 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:
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.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:
To revert to the default icon for a selected 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.