Skip Menu |

This queue is for tickets about the Template-Toolkit CPAN distribution.

Report information
The Basics
Id: 49923
Status: rejected
Priority: 0/
Queue: Template-Toolkit

People
Owner: Nobody in particular
Requestors: jd [...] cpanel.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 2.22
Fixed in: (no value)



Subject: Template::Stash::define_vmethod() should be object method instead of class method
I was looking at a Template::Plugin subclass that another developer had written and was left wondering why the vmethod mappings are stored at the class level in Template::Stash rather than being kept inside the individual Template::Stash objects. It seems like it would be more sensible to do something like: my $stash = $context->stash(); $stash->define_vmethod('scalar', 'something', sub { ... }); Instead of Template::Stash->define_vmethod('scalar', 'something', sub {...});
On Tue Sep 22 15:55:26 2009, jlightsey wrote: Show quoted text
> It seems like it would be more sensible to do something like: > > my $stash = $context->stash(); > $stash->define_vmethod('scalar', 'something', sub { ... }); > > Instead of > > Template::Stash->define_vmethod('scalar', 'something', sub {...});
The benefit of having them stored in a package variable is that code can add new virtual methods without having to have a stash instance. e.g. they can be added before a Template object is created. Any change to this would break existing code, so I'm going to reject it for now, but I'll consider it for the next major version. Thanks for bringing it to my attention all the same.