[Templates] Modifying TT functions at run time
darren chamberlain
dlc@users.sourceforge.net
Mon, 4 Nov 2002 10:01:50 -0500
* Simon Wilcox <essuu@ourshack.com> [2002-11-04 09:38]:
> Is it possible to add a function like this at runtime or should I just
> bite the bullet and write a plugin ?
Nothing springs to mind that would help you -- a user can't load
arbitrary Perl modules into a Template unless USE_PERL is set in the
Template constructor (security feature). I think a plugin is your best
plan:
package Template::Plugin::ImageSize;
use strict;
use base qw(Template::Plugin);
use Image::Size;
sub imgsize {
my ($self, $context, $image) = @_;
return imgsize($image);
}
sub attr_imgsize {
my ($self, $context, $image) = @_;
return attr_imgsize($image);
}
sub html_imgsize {
my ($self, $context, $image) = @_;
return html_imgsize($image);
}
1;
(darren)
--
Once you eliminate the impossible, whatever remains, no matter how
improbable, must be the truth.
-- Sherlock Holmes