[Templates] Template::Plugin::Procedural

Mark Fowler mark@twoshortplanks.com
Mon, 2 Sep 2002 19:48:59 +0100 (BST)


Another random Idea for the Template Toolkit:

=head1 NAME

Template::Plugin::Procedural - Base class for procedural plugins

=head1 SYNOPSIS

    package Template::Plugin::LWPSimple;
    use base qw(Template::Plugin::Procedural);
    use LWP::Simple;  # exports 'get'
    1;

    [% USE LWPSimple %]
    [% LWPSimple.get("http://www.tt2.org/") %]

=head1 DESCRIPTION

B<Template::Plugin::Procedural> is a base class for Template Toolkit
plugins that causes defined subprocedures to be called directly
rather than as a method.  Essentially this means that subroutines will
not receive the class name or object as its first argument.

This is most useful when creating plugins for modules that normally
work by exporting subroutines that do not expect such additional
arguments.

Despite the fact that procedures will not be called in an OO manner,
inheritance still functions as normal.  A class that uses
B<Template::Plugin::Procedural> can be subclassed and both subprocedures
defined in the subclass and subprocedures defined in the original
class will be available to the Template Toolkit and will be called
without the class/object argument.


Is all done and has passing tests.  Should I go ahead and commit it in?

Oh, and if I do, what should I do about Changes?  Start a section for a 
new developer release?

Mark.

-- 
s''  Mark Fowler                                     London.pm   Bath.pm
     http://www.twoshortplanks.com/              mark@twoshortplanks.com
';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/  +/
){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}