NAME

Top Close Open

Template::TT3::Factory - base class for factory modules

SYNOPSIS

Top Close Open
# This module is used internally to create factory modules responsible 
# for loading other modules.  e.g. Template::TT3::Engines.

package Template::TT3::Engines;

use Template::TT3::Class::Factory
    version   => 3.00,
    debug     => 0,
    item      => 'engine',
    path      => 'Template(X)::(TT3::|)Engine';

DESCRIPTION

Top Close Open

This module is a common base class for all TT3 factory modules that are responsible for loading other modules. For example, the Template::TT3::Engines modules is a factory module for loading Template::TT3::Engine::* modules.

Template::TT3::Factory is a thin subclass of Badger::Factory . It exists to provide a convenient place to define any functionality or declarations that are common to all TT3 factory modules.

The Template::TT3::Class::Factory module is defined as a thin wrapper around Badger::Factory::Class to aid in the construction of factory modules.

METHODS

Top Close Open

This module implements the following methods in addition to those inherited from the Template::TT3::Base , Badger::Factory and Badger::Base base classes.

init($config)

Top Close Open

This is an alias to the init_factory() method. It replaces the default init() method inherited from Badger::Factory .

init_factory($config)

Top Close Open

This is a thin wrapper around the init_factory() method inherited from Badger::Factory . It performs some additional configuration to make the declarations in $MAP accessible to subclasses.

PACKAGE VARIABLES

Top Close Open

This module defines the following package variables. These are declarations that are used by the Badger::Factory base class.

$NAMES

Top Close Open

This defines a lookup table for resolving modules with alternate spellings or unusual capitalisations (where "unusual" is defined as anything that can't be resolved automatically).

The Badger::Factory base class module uses the camel_case() function to construct a full module name from a short identifier passed to it. It appends the resultant name to each module base specified in its path and attempts to load the module. For example, consider a factory with a path defined as follows:

my $widgets = Badger::Factory->new(
    item => 'widget',
    path => ['Foo', 'Bar']
);

Requesting an item named wiz_bang will instruct the factory to look for a wiz_bang module as either Foo::WizBang or Bar::WizBang.

# load and instantiate either Foo::WizBang or Bar::WizBang
my $widget = $widgets->widget('wiz_bang');

In the case of modules whose names include capitalised acronyms, specifically "TT2", "TT3" and "HTML", a request for a lower case equivalent, "tt2", "tt3" or "html" will generate incorrect capitalisations of "Tt2", "Tt3" and "Html" respectively.

The $NAMES table define correct capitalisations for these values. These definitions are then inherited by all other TT3 factory modules.

our $NAMES = {
    tt2     => 'TT2',
    tt3     => 'TT3',
}

$DEFAULT

Top Close Open

This defines the default value for TT3 factort modules to be TT3. e.g. the default engine returned by Template::TT3::Engines is the TT3 engine implemented as Template::TT3::Engine::TT3 .

AUTHOR

Top Close Open

Andy Wardley http://wardley.org/

COPYRIGHT

Top Close Open

Copyright (C) 1996-2009 Andy Wardley. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO.

Top Close Open

This module inherits methods from the Template::TT3::Base , Badger::Factory , and Badger::Base base classes.

It is itself the base class for Template::TT3::Engines , Template::TT3::Dialects , Template::TT3::Providers , and various other factory modules.


http://tt3.template-toolkit.org/docs/Template/TT3/Factory.pm last modified 2009-12-21 10:17:07