NAME

Top Close Open

Template::TT3::Base - base class for other TT modules

SYNOPSIS

Top Close Open
package Template::TT3::ExampleModule;

use Template::TT3::Class
    version => 3.00,
    base    => 'Template::TT3::Base';

DESCRIPTION

Top Close Open

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.

METHODS

Top Close Open

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.

init_hub($config)

Top Close Open

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.

hub()

Top Close Open

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() .

self()

Top Close Open

A trivial method that simply returns the $self object reference. This is typically used by Template::TT3::Element objects as a no-op shortcut.

raise_error($type,$params)

Top Close Open

Used to raise exceptions of a particular type. The $type is forwarded to Template::TT3::Exception to locate the appropriate exception module.

token_error($type,$token,$message)

Top Close Open

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.

token_error_msg($token, $format, @args)

Top Close Open

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.

syntax_error($token, $message)

Top Close Open

A wrapper around token_error() use to raise syntax errors.

syntax_error_msg($token, $message)

Top Close Open

A wrapper around token_error_msg() use to raise syntax errors.

undef_error($token, $message)

Top Close Open

A wrapper around token_error() use to raise errors relating to undefined data values.

undef_error_msg($token, $format, @args)

Top Close Open

A wrapper around token_error_msg() use to raise undefined data errors.

resource_error($token, $message)

Top Close Open

A wrapper around token_error() use to raise errors relating to missing or invalid resources (templates, files, plugins, etc).

resource_error_msg($token, $format, @args)

Top Close Open

A wrapper around token_error_msg() use to raise resource errors.

dump_data_depth($data, $depth)

Top Close Open

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 .

INTERNAL METHODS

Top Close Open

The following methods are defined for internal use.

_exceptions()

Top Close Open

This method loads the Template::TT3::Exceptions module and returns its class name.

_exception()

Top Close Open

This method instantiates an exception object using the Template::TT3::Exceptions factory module loaded via the _exceptions() method.

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 Badger::Base base classes. It also mixes in the methods exported from the Badger::Debug module's :debug and :dump tag sets.


http://tt3.template-toolkit.org/docs/Template/TT3/Base.pm last modified 2009-12-22 09:57:05