Template-Plugin-Class-0.13/0000775000076700001200000000000010430326743016401 5ustar richardcadmin00000000000000Template-Plugin-Class-0.13/Build.PL0000664000076700001200000000046010430326743017675 0ustar richardcadmin00000000000000use strict; use Module::Build; Module::Build->new( module_name => "Template::Plugin::Class", license => 'perl', build_requires => { 'Test::More' => 0, }, requires => { 'Template' => 0, }, create_makefile_pl => 'traditional', )->create_build_script; Template-Plugin-Class-0.13/Changes0000664000076700001200000000072610430326743017701 0ustar richardcadmin000000000000000.13 Wednesday 10th May, 2006 Make it work correctly when diagnostics.pm is in use. http://rt.cpan.org/Ticket/Display.html?id=11538 Changed to ship a traditional Makefile.PL Pulled the copy about rt.cpan.org from L 0.12 Tuesday 13th January, 2004 Make the require logic softer by stealing from base.pm. https://rt.cpan.org/Ticket/Display.html?id=4897 0.11 Tuesday 26th August, 2003 test suite fixup 0.10 Saturday 15th August, 2003 initial CPAN release Template-Plugin-Class-0.13/lib/0000775000076700001200000000000010430326743017147 5ustar richardcadmin00000000000000Template-Plugin-Class-0.13/lib/Template/0000775000076700001200000000000010430326743020722 5ustar richardcadmin00000000000000Template-Plugin-Class-0.13/lib/Template/Plugin/0000775000076700001200000000000010430326743022160 5ustar richardcadmin00000000000000Template-Plugin-Class-0.13/lib/Template/Plugin/Class.pm0000664000076700001200000000376610430326743023577 0ustar richardcadmin00000000000000use strict; package Template::Plugin::Class; use base 'Template::Plugin'; use vars qw( $VERSION ); $VERSION = '0.13'; sub new { my $class = shift; my $context = shift; my $arg = shift; # stolen from base.pm eval "require $arg"; # Only ignore "Can't locate" errors from our eval require. # Other fatal errors (syntax etc) must be reported. (my $filename = $arg) =~ s!::!/!g; die if $@ && $@ !~ /Can't locate \Q$filename\E\.pm/; no strict 'refs'; unless (%{"$arg\::"}) { require Carp; Carp::croak("Package \"$arg\" is empty.\n", "\t(Perhaps you need to 'use' the module ", "which defines that package first.)"); } return bless \$arg, 'Template::Plugin::Class::Proxy'; } package Template::Plugin::Class::Proxy; use vars qw( $AUTOLOAD ); sub AUTOLOAD { my $self = shift; my $class = ref $self; my ($method) = ($AUTOLOAD =~ /^$class\::(.*)/); $$self->$method(@_); } sub DESTROY {} 1; __END__ =head1 NAME Template::Plugin::Class - allow calling of class methods on arbitrary classes =head1 SYNOPSIS [% USE foo = Class('Foo') %] [% foo.bar %] =head1 DESCRIPTION Template::Plugin::Class allows you to call class methods on arbitrary classes. One use for this is in Class::DBI style applications, where you may do somthing like this: [% USE cd = Class('Music::CD') %] [% FOREACH disc = cd.retrieve_all %] [% disc.artist %] - [% disc.title %] [% END %] =head1 CAVEATS You won't be able to directly call C or C methods on the remote class. This shouldn't be a huge hardship. =head1 BUGS Apart from the mentioned caveat, none currently known. If you find any please contact the author. =head1 AUTHOR Richard Clamp =head1 COPYRIGHT Copyright (C) 2003, 2004, 2006 Richard Clamp. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L