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.
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
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.
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:
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 Project|New From Template and choose from one of the available templates.
To save any project as a template, click Project|New From Template|Create Template From Project... and select a location to save the template (e.g. the My Templates directory).
Komodo ships with project templates for, Ruby on Rails, Komodo Extensions, and Firefox Extensions.
To store a template in a Toolbox, save the template as described above, select Add|New Template... from the Toolbox drop-down menu or context menu, and choose your new template from the category you saved it in (e.g. My Templates).
Right-click a template to access the following options:
© 2017 ActiveState Software Inc. All rights reserved. ActiveState®,
Komodo®, ActivePerl®, ActivePython®, and ActiveTcl® are registered
trademarks of ActiveState.
All other marks are property of their respective owners.