Note: ExtUtils::ModuleMaker has changed substantially in recent releases and ExtUtils::ModuleMaker::TT has similarly changed substantially to be compatible with these changes. Please report any bugs you may find.

This module extends ExtUtils::ModuleMaker to use Template Toolkit 2 (TT2) to build skeleton files for a new module. Templates may either be default templates supplied within the module or user-customized templates in a directory specified with the TEMPLATE_DIR parameter.

Summary of Features/Enhancements:

Supports building full module skeletons with all the functionality of ExtUtils::ModuleMaker

Templates can access any parameter in the ExtUtils::ModuleMaker object (e.g. $mmtt, above). This supports transparent, user-extensible template variables for use in custom templates

Included command-line program makeperlmod provides a command line user interface for module creation. Supports reading default configuration settings from a file and will create a default config file if requested. These config files extend and/or override an ExtUtils::ModuleMaker::Personal::Defaults file. The program can create full distributions, single modules, single methods, default configuration files or default template directories

Notable changes from ExtUtils::ModuleMaker:

Default templates are generally simpler, as users are expected to customize their own

.t files for single .pm files created after the original build are named after their corresponding .pm file rather than being sequentially numbered.

Generally, users should just use the included command-line program, makeperlmod. For example, the following command will create a module distribution using default settings:

makeperlmod -n Sample::Module

See the makeperlmod manual page for details on creating a custom configuration file (for setting author details and other ExtUtils::ModuleMaker options) that will extend or override defaults set in an ExtUtils::ModuleMaker::Personal::Defaults file. The "CUSTOMIZING TEMPLATES" section below contains other examples.

When specified as the ALT_BUILD, ExtUtils::ModuleMaker::TT provides several additional methods as described below. The makeperlmod source provides a practical example of such usage.

The $module parameter may be either a hash reference containing configuration options (including NAME) or a string containing the name of a module, in which case the default configuration will be used. E.g.:

$module = { NAME => 'Sample::Module', NEED_POD => 0 };

or

$module = 'Sample::Module';

This method must be able to locate the base directory of the distribution in order to correctly place the .pm and .t files. A complete_build() call sets the Base_Dir parameter appropriately as it creates the distribution directory. When called on a standalone basis (without a prior complete_build() call), the caller must be in a directory within the distribution tree.

When Base_Dir is not set, this method will look in the current directory for both a 'MANIFEST' file and a 'lib' directory. If neither are found, it will scan upwards in the directory tree for an appropriate directory. Requiring both files prevents mistakenly using either a template directory or a unix root directory. The method will croak if a proper directory cannot be found. The working directory in use prior to the method being called will be restored when the method completes or croaks. Returns a true value if successful.

Creates the named $directory and populates it with a file for each default template. These can be customized and the directory used in conjunction with the TEMPLATE_DIR configuration options. See "CUSTOMIZING TEMPLATES", below. Returns a true value if successful.

Calls TT2 to fill in the given template and write it to the output file. Requires a template name, a hash reference of parameters (typically just the $mmtt object itself), and an outputfile (relative to the base distribution directory). If the TEMPLATE_DIR parameter is set, templates will be taken from there, otherwise the default templates are used. Returns a true value if successful.

Use the makeperlmod script to create a directory containing a copy of the default templates. Alternatively, use the create_template_directory method directly. Edit these templates to suit personal taste or style guidelines. Be sure to specify a TEMPLATE_DIR configuration option when making modules or add it to either the ExtUtils::ModuleMaker::Personal::Defaults file or to a makeperlmod config file.

This will create a default configuration file and print its location. See the makeperlmod manual for details on creating and using named configuration files.

Next, create a template directory. Choose a location that is appropriate for your operating system. E.g., for unix:

makeperlmod -t ~/.makeperlmod.templates

Edit the templates as needed. Templates are written with the Template Toolkit to allow for easy user customization of the contents and layout. See the Template module for the full syntax or just examine the default templates for quick changes.

Edit the default configuration file and add a TEMPLATE_DIR parameter. Use whatever directory you chose to hold the templates. Make any other desired edits to AUTHOR, etc. For example:

When templates are processed, the entire ExtUtils::ModuleMaker object is passed to the Template Toolkit. Thus any class data is available for use in templates. Users may add custom configuration options ( to new, to the ExtUtils::ModuleMaker::Personal::Defaults file, or to a makeperlmod config file) and use these in custom templates. Be careful not to overwrite any class data needed elsewhere in the module.