Thursday, March 29, 2007

Template Toolkit CGI.pmの例

use strict;
use Template;
use CGI;
my $q = CGI->new;
print "Content-type: text/html\n\n";

my $output;
my $template = Template->new({
OUTPUT => \$output,
TRIM =>1,
});

$template->process(
'fillin.html',
{
apr =>$q,
},
) or print $template->error;
print $output;

-----
[% USE FillInForm %]
[% FILTER fillinform fobject => apr %]

<!-- this form becomes sticky -->
<form action="foo" method="POST">
<input type="text" name="foo">
<input value="" type="hidden" name="bar">
<input value="foo" type="radio" checked name="baz">
<input value="bar" type="radio" name="baz">
</form>
[% END %]

No comments: