use Template::TT3::Engines; # class methods $engine = Template::TT3::Engines->engine; # default engine (TT3) $engine = Template::TT3::Engines->engine('TT2'); # specific engine # object methods $engines = Template::TT3::Engines->new; $engine = $engines->engine; $engine = $engines->engine('TT2'); # object with configuration options $engines = Template::TT3::Engines->new( path => ['My::Engine', 'Your::Engine'], ); $engine = $engines->engine; $engine = $engines->engine('TT2');
This module is a subclass of Template::TT3::Factory for locating, loading and instantiating template engine modules.
It searches for engine modules in the following places:
Template::TT3::Engine Template::Engine TemplateX::TT3::Engine TemplateX::Engine
For example, requesting a TT2
engine returns a
Template::TT3::Engine::TT2
object.
my $engine = Template::TT3::Engines->engine('TT2');
The default engine type is TT3
, returned as a
Template::TT3::Engine::TT3
object.
my $engine = Template::TT3::Engines->engine; my $engine = Template::TT3::Engines->engine('default'); # same thing
The following configuration options are defined in addition to those inherited from the Template::TT3::Factory , Template::TT3::Base , Badger::Factory and Badger::Base base classes.
They should be specified as a list or reference to a hash array of named parameters when the factory object is created.
# either a list of named parameters... my $engines = Template::TT3::Engines->new( engine_path => [ 'My::Engine', 'Template::TT3::Engine' ], ); # ...or a reference to a hash array my $engines = Template::TT3::Engines->new({ engine_path => [ 'My::Engine', 'Template::TT3::Engine' ], });
A reference to a hash array explicitly mapping internal engine names to external Perl modules. This can be used to override and/or augment the engine modules that the factory would normally be able to locate automatically.
my $engines = Template::TT3::Engines->new( engines => { foo => 'Some::Other::Engine::Foo', bar => 'Yet::Another::Engine::Bar' }, );
A reference to a list of module namespaces that the factory should search to locate engine modules. The default path is defined by the $PATH package variable.
my $engines = Template::TT3::Engines->new( engine_path => [ 'My::Engine', 'Template::TT3::Engine' ], );
This module inherits all methods from the Template::TT3::Factory , Template::TT3::Base , Badger::Factory and Badger::Base base classes. The following methods are automatically provided by the Badger::Factory base class.
Locates, loads and instantiates an engine module. This is created as an alias to the item() method in Badger::Factory .
Method for inspecting or modifying the engines that the factory module manages. This is created as an alias to the items() method in Badger::Factory .
This module defines the following package variables. These are declarations that are used by the Badger::Factory base class.
This is the name of the item that the factory module returns, and implicitly
the name of the method by which engine objects can be created. In this case it
is defined as engine
.
Andy Wardley http://wardley.org/
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.
This module inherits methods from the Template::TT3::Factory , Template::TT3::Base , Badger::Factory , and Badger::Base base classes.
It is constructed using the Template::TT3::Class::Factory class metaprogramming module.
It loads modules and instantiates object that are subclasses of Template::TT3::Engine . See Template::TT3::Engine::TT2 and Template::TT3::Engine::TT3 for examples.