I have a really tiny patch for the Image plugin that makes things
slightly easier when subclassing Template::Plugin::Image. In the
'tag' method, the filename is grabbed directly from the $self hash,
instead of using the 'name' accessor.
In my subclass, I change the value of the filename that is provided by
the user. But the change is not picked up until 'init' get's
executed, and 'init' doesn't get called until an accessor is called.
So if a new Image object is created, and 'tag' is called immediately,
then 'name' will be picked up before 'init' gets a chance to alter it.
This problem doesn't affect users of the Image plugin, it only
potentially affects subclasses that want to change the filename. The
patch also shouldn't affect users of the Image Plugin as a call to
$self->name() will just return the value of $self->{ name }.
Cheers,
Cees
--- Image.pm.orig 2006-02-20 13:44:12.000000000 -0500
+++ Image.pm 2006-02-20 13:45:49.000000000 -0500
@@ -164,7 +164,7 @@
my $self = shift;
my $options = ref $_[0] eq 'HASH' ? shift : { @_ };
- my $tag = "<img src=\"$self->{ name }\" " . $self->attr();
+ my $tag = '<img src="' . $self->name() . '" ' . $self->attr();
# XHTML spec says that the alt attribute is mandatory, so who
# are we to argue?