[Templates] How To Throw Exception on Missing Method

Matisse Enzer menzer@apple.com
Thu, 26 Jul 2007 20:10:22 -0700


On Jul 26, 2007, at 1:11 PM, Paul Seamons wrote:

>> Here is some quick untested pseudo code.
>
> And here it is on Template::Alloy:
>
> use Template::Alloy;
> use Scalar::Util qw(blessed);
>
> my $tt = Template::Alloy->new(UNDEFINED_ANY => sub {
>     my ($self, $ident) = @_;
>     return '' if ! ref $ident;
>     my ($obj, $args, $dot, $meth) = @$ident;
>     return '' if ! blessed($obj) || $obj->can($meth);
>
>     $self->throw('invalid_method', "Bad method $meth on class ".ref 
> ($obj));
> });

This is interesting - I had not heard of Template::Alloy - I just  
read the DESCRIPTION and might give this a try.

I go on vacation for this weekend so maybe after I get back next  
week, or maybe before :-)

Thank you.

------------------------------------
Matisse Enzer
menzer@apple.com