use Template::TT3::Dialects; # class methods $dialect = Template::TT3::Dialects->dialect; # default dialect (TT3) $dialect = Template::TT3::Dialects->dialect('TT2'); # specific dialect # object methods $dialects = Template::TT3::Dialects->new; $dialect = $dialects->dialect; $dialect = $dialects->dialect('TT2'); # object with configuration options $dialects = Template::TT3::Dialects->new( path => ['My::Dialect', 'Your::Dialect'], ); $dialect = $dialects->dialect; $dialect = $dialects->dialect('TT2');
This module is a subclass of Template::TT3::Factory for locating, loading and instantiating template dialect modules.
It searches for dialect modules in the following places:
Template::TT3::Dialect Template::Dialect TemplateX::TT3::Dialect TemplateX::Dialect
For example, requesting a TT2
dialect returns a
Template::TT3::Dialect::TT2
object.
my $dialect = Template::TT3::Dialects->dialect('TT2');
The default dialect type is TT3
, returned as a
Template::TT3::Dialect::TT3
object.
my $dialect = Template::TT3::Dialects->dialect; my $dialect = Template::TT3::Dialects->dialect('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 $dialects = Template::TT3::Dialects->new( dialect_path => [ 'My::Dialect', 'Template::TT3::Dialect' ], ); # ...or a reference to a hash array my $dialects = Template::TT3::Dialects->new({ dialect_path => [ 'My::Dialect', 'Template::TT3::Dialect' ], });
A reference to a hash array explicitly mapping internal dialect names to external Perl modules. This can be used to override and/or augment the dialect modules that the factory would normally be able to locate automatically.
my $dialects = Template::TT3::Dialects->new( dialects => { foo => 'Some::Other::Dialect::Foo', bar => 'Yet::Another::Dialect::Bar' }, );
A reference to a list of module namespaces that the factory should search to locate dialect modules. The default path is defined by the $PATH package variable.
my $dialects = Template::TT3::Dialects->new( dialect_path => [ 'My::Dialect', 'Template::TT3::Dialect' ], );
This module implements the following methods in addition to those inherited from the Template::TT3::Factory , Template::TT3::Base , Badger::Factory and Badger::Base base classes.
This method replaces the default found() method inherited from Badger::Factory . It is called by the factory base class when a module is found and loaded. It implements some additional functionality specific to the instantiation of dialect objects.
Locates, loads and instantiates a dialect module. This is created as an alias to the item() method in Badger::Factory .
Method for inspecting or modifying the dialects 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 dialects can be created. In this case it is
defined as dialect
.
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::Dialect . See Template::TT3::Dialect::TT3 for an example.