---------- Forwarded message ----------
Date: Sat, 10 Aug 2002 20:45:49 +0800
From: cs_cwt <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Help: HTML::Template Problem

Dear Sam,

I am a user of HTM::Template. I think HTML::Template is a great module, it completely 
divides the implementation of the front end and the back end. But I have a little 
problem when using it, would you mind to answer me my question, please?

In my template,
<html><body>
<tmpl_loop record>
<tmpl_var names>
<tmpl_var ages>
</tmpl_loop>
</body></html>

In my perl script,
...
use HTML::Template;
my $htmltemplate = HTML::Template->new("template.htm");
my %myHash;
my @myRecord = [];

for(int $i=0; $i<3; $i++)
{
foreach my $obj($htmltemplate->query(loop=>"record"))
{
$myHash{$obj} = "Tom".$i;
}
push (@myRecord, %myHash);
}
$htmltemplate->param(record=>@myRecord);
$htmltemplate->output();
...

I got error from the above usage. It prompted me that it could not find the variable 
names. But if I change to the following

...
use HTML::Template;
my $htmltemplate = HTML::Template->new("template.htm");
my %myHash;
my @myRecord = [{names=>"Tom0", age=>"Tom0}, {names=>"Tom1", age=>"Tom1}, 
{names=>"Tom2", age=>"Tom2} ];
$htmltemplate->param(record=>@myRecord);
$htmltemplate->output();
...

The above did not prompt any error. Could you tell me the difference, please? Could 
you teach me how to insert data into HTML::Template's loop
dynamically, please? Thanks a lot.

cwt




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to