package Template::TT3::ExampleModule; use Template::TT3::Class version => 3.00, base => 'Template::TT3::Base';
This module implements a common base class for all other TT3 modules. It is
itself a subclass of
Badger::Base
which provides the bulk of the
functionality. Template::TT3::Base
adds a number of methods that are
specific to the Template Toolkit.
This module implements the following methods in addition to those inherited from the Badger::Base base class module. Most, if not all of these methods are intended for internal use within subclass modules.
A custom initialisation object method which looks for a
hub
reference in the $config
configuration parameters
and stores it in the $self
object. If a hub is not defined as a
configuration parameter then it automatically loads
Template::TT3::Hub
and uses its prototype (singleton) object.
An accessor method which returns the current hub reference (a Template::TT3::Hub object). It throws an error if no hub is available. See init_hub() .
A trivial method that simply returns the $self
object reference. This is
typically used by
Template::TT3::Element
objects as a no-op shortcut.
Used to raise exceptions of a particular type. The $type
is forwarded
to
Template::TT3::Exception
to locate the appropriate exception module.
Used to raise exceptions of a particular type from the perspective of a particular token element. This is typically used to report syntax errors, undefined data errors, missing resource errors, and any other kind of error that relates to a particular source code fragment.
NOTE: This and the other related methods listed below should probably be moved into the Template::TT3::Element base class.
This method is a wrapper around
token_error()
use that uses the
message()
method inherited from
Badger::Base
to present the error using a pre-defined (in $MESSAGES
) message format.
A wrapper around token_error() use to raise syntax errors.
A wrapper around token_error_msg() use to raise syntax errors.
A wrapper around token_error() use to raise errors relating to undefined data values.
A wrapper around token_error_msg() use to raise undefined data errors.
A wrapper around token_error() use to raise errors relating to missing or invalid resources (templates, files, plugins, etc).
A wrapper around token_error_msg() use to raise resource errors.
This is a temporary method used for debugging. It is a wrapper around the
dump_data()
method which is mixed in from
Badger::Debug
. The $depth
argument can be set to limit to depth to
which the data dumper will traverse.
TODO: This method should probably be moved into Badger::Debug .
The following methods are defined for internal use.
This method loads the Template::TT3::Exceptions module and returns its class name.
This method instantiates an exception object using the Template::TT3::Exceptions factory module loaded via the _exceptions() method.
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 Badger::Base base classes. It also mixes in the methods exported from the Badger::Debug module's :debug and :dump tag sets.