Hi,

I have noticed that the module HTML::Template::Compiled stores the vars in
memory when using mod_perl, and possibly displays them for the next visitor.

I have created the following test mod_perl handler using the template below
it.

Note: If I just change HTML::Template::Compiled with HTML::Template, the
program works fine, with no errors.
Am I doing something wrong?

The program:

package Presa::User;

use strict;
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Const -compile => qw(:common);

use CGI qw(:standard);
use HTML::Template::Compiled ();

sub handler {
my $r = shift;

my $q = CGI->new($r);

if ($q->param('sent')) {
#The form was sent
my $foo = $q->param('foo');
my $bar = $q->param('bar');

my %vars = (
title => 'Sample title 2',
foo => $foo,
bar => $bar,
);

my $ht = HTML::Template::Compiled->new(
path => 'e:/web/presaromana/templates',
filename => 'to_delete.html',
);

$ht->param(%vars);

$r->content_type('text/html');
$r->headers_out();
$r->print($ht->output());

undef $ht;

return Apache2::Const::OK;
}
else {
#The form was not sent. Print just the form
my $ht = HTML::Template::Compiled->new(
path => 'e:/web/presaromana/templates',
filename => 'to_delete.html',
);

$ht->param(title => 'Sample title 1');

$r->content_type('text/html');
$r->headers_out();
$r->print($ht->output());
undef $ht;

return Apache2::Const::OK;
}

#end sub handler
}

1;


The template:

<html>
<head><title><TMPL_VAR name=title></title></head>
<body>
<TMPL_IF name=foo>Foo: <TMPL_VAR name=foo></TMPL_IF>
<br />
<TMPL_IF name=bar>bar: <TMPL_VAR name=bar></TMPL_IF>
<br />
<form action="/user" method="post">
<input type="hidden" name="sent" value="1" />
Foo: <input type="text" name="foo" value="<TMPL_IF name=foo><TMPL_VAR
name=foo></TMPL_IF>" /><br />
bar: <input type="text" name="bar" value="<TMPL_IF name=bar><TMPL_VAR
name=bar></TMPL_IF>" /><br />
<input type="submit">
</form>
</body>
</html>


Teddy




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to