root/Template-Plugin-FillInForm/trunk/lib/Template/Plugin/FillInForm.pm

Revision 605 (checked in by miyagawa, 18 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 package Template::Plugin::FillInForm;
2
3 use strict;
4 use vars qw($VERSION);
5 $VERSION = 0.01;
6
7 require Template::Plugin::Filter;
8 use base qw(Template::Plugin::Filter);
9
10 use vars qw($DYNAMIC $FILTER_NAME);
11 $DYNAMIC = 1;
12 $FILTER_NAME = 'fillinform';
13
14 use HTML::FillInForm;
15
16 sub init {
17     my $self = shift;
18     my $name = $self->{_ARGS}->[0] || $FILTER_NAME;
19     $self->install_filter($name);
20     return $self;
21 }
22
23 sub filter {
24     my($self, $text, $args, $config) = @_;
25     my $fif = HTML::FillInForm->new;
26     return $fif->fill(scalarref => \$text, %$config);
27 }
28
29
30 1;
31 __END__
32
33 =head1 NAME
34
35 Template::Plugin::FillInForm - TT plugin for HTML::FillInForm
36
37 =head1 SYNOPSIS
38
39   use Template;
40   use Apache;
41   use Apache::Request;
42
43   my $apr      = Apache::Request->new(Apache->request); # or CGI.pm will do
44   my $template = Template->new( ... );
45   $template->process($filename, { apr => $apr });
46
47   # in your template
48   [% USE FillInForm %]
49   [% FILTER fillinform fobject => apr %]
50   <!-- this form becomes sticky -->
51   <form action="foo" method="POST">
52   <input type="text" name="foo">
53   <input type="hidden" name="bar">
54   <input type="radio" name="baz" value="foo">
55   <input type="radio" name="baz" value="bar">
56   </form>
57   [% END %]
58
59 =head1 DESCRIPTION
60
61 Template::Plugin::FillInForm is a plugin for TT, which allows you to
62 make your HTML form sticky using HTML::FillInForm.
63
64 =head1 AUTHOR
65
66 Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
67
68 This library is free software; you can redistribute it and/or modify
69 it under the same terms as Perl itself.
70
71 =head1 SEE ALSO
72
73 L<Template>, L<HTML::FillInForm>
74
75 =cut
Note: See TracBrowser for help on using the browser.