template::base(3)
NAME
Template::Base - Base class module implementing common
functionality
SYNOPSIS
package Template::MyModule;
use base qw( Template::Base );
sub _init {
my ($self, $config) = @_;
$self->{ doodah } = $config->{ doodah }
|| return $self->error("No 'doodah' specified");
return $self;
}
DESCRIPTION
Base class module which implements a constructor and error
reporting functionality for various Template Toolkit mod
ules.
PUBLIC METHODS
new%(config)
- Constructor method which accepts a reference to a hash
array or a list of "name => value" parameters which are
folded into a hash. The _init() method is then called,
passing the configuration hash and should return
true/false to indicate success or failure. A new object
reference is returned, or undef on error. Any error mes
sage raised can be examined via the error() class method or directly via the package variable ERROR in the derived
class. - my $module = Template::MyModule->new({ ... })
|| die Template::MyModule->error(), "0;
- my $module = Template::MyModule->new({ ... })
|| die "constructor error: $Template::MyModule::ERROR0;
- error($msg)
- May be called as an object method to get/set the internal
_ERROR member or as a class method to get/set the $ERROR
variable in the derived class's package.
my $module = Template::MyModule->new({ ... })|| die Template::MyModule->error(), "0;- $module->do_something()
|| die $module->error(), "0;
- When called with parameters (multiple params are concate
nated), this method will set the relevant variable and
return undef. This is most often used within object meth
ods to report errors to the caller.
package Template::MyModule;- ...
- sub foobar {
my $self = shift;
...
return $self->error('some kind of error...')if $some_condition;... - }
AUTHOR
Andy Wardley <abw@andywardley.com>
<http://www.andywardley.com/|http://www.andywardley.com/>
VERSION
2.54, distributed as part of the Template Toolkit version
2.08, released on 30 July 2002.
COPYRIGHT
- Copyright (C) 1996-2002 Andy Wardley. All Rights Re
- served.
Copyright (C) 1998-2002 Canon Research Centre Europe - Ltd.
- This module is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
SEE ALSO
- Template