Changeset 799

Show
Ignore:
Timestamp:
11/14/02 19:10:05
Author:
miyagawa
Message:

0.04

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Template-Plugin-FillInForm/trunk/Changes

    r769 r799  
    11Revision history for Perl extension Template::Plugin::FillInForm 
     2 
     30.04  Thu Nov 14 19:08:50 JST 2002 
     4        * Fixed memory leaks due to Template::Plugin::Filter 
    25 
    360.03  Wed Sep 18 11:51:44 JST 2002 
  • Template-Plugin-FillInForm/trunk/lib/Template/Plugin/FillInForm.pm

    r769 r799  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.03
     5$VERSION = 0.04
    66 
    7 require Template::Plugin::Filter
    8 use base qw(Template::Plugin::Filter); 
     7require Template::Plugin
     8use base qw(Template::Plugin); 
    99 
    10 use vars qw($DYNAMIC $FILTER_NAME); 
    11 $DYNAMIC = 1; 
     10use vars qw($FILTER_NAME); 
    1211$FILTER_NAME = 'fillinform'; 
    1312 
    1413use HTML::FillInForm; 
    1514 
    16 sub init
    17     my $self = shift
    18     my $name = $self->{_ARGS}->[0] || $FILTER_NAME; 
    19     $self->install_filter($name); 
    20     return $self
     15sub new
     16    my($class, $context, @args) = @_
     17    my $name = $args[0] || $FILTER_NAME; 
     18    $context->define_filter($name, $class->filter_factory()); 
     19    bless {}, $class
    2120} 
    2221 
    23 sub filter { 
    24     my($self, $text, $args, $config) = @_; 
    25     my $fif = HTML::FillInForm->new; 
    26     return $fif->fill(scalarref => \$text, %$config); 
     22sub filter_factory { 
     23    my $class = shift; 
     24    my $sub = sub { 
     25        my($context, @args) = @_; 
     26        my $config = ref $args[-1] eq 'HASH' ? pop(@args) : { }; 
     27        return sub { 
     28            my $text = shift; 
     29            my $fif = HTML::FillInForm->new; 
     30            return $fif->fill(scalarref => \$text, %$config); 
     31        }; 
     32    }; 
     33    return [ $sub, 1 ]; 
    2734} 
    28  
    2935 
    30361;