On Wed, 6 Feb 2002, Lyle Brooks wrote:
> I wonder how many Plugin solutions could be more effectively written
> with one of these "non-Plugin" alternatives?
Yesterday I think I found a reason to write a plugin. I wanted to access a
module that had only a functional interface. I couldn't just pass it in as
a subref as I am using ttree which doesn't seem to support it.
So I wrote a quick plugin around it which does just what I want but is
probably far from perfect.
So my guideline now is "Write a plugin to encapsulate functional
interfaces but only when you can't pass the function into the template as
a subref"
Since it is relevant to an earlier post about Image::Size, I've attached
it here in case it helps anyone.
Simon.
package SMW::Template::Plugin::ImageSize;
use strict;
use vars qw( $VERSION );
use base qw( Template::Plugin );
use Image::Size;
$VERSION = '0.01';
sub new {
my $class = shift;
my $context = shift;
return bless {}, $class;
}
sub html_imgsize {
my $self = shift;
my $img = shift;
return Image::Size::html_imgsize($img);
}
1;