On Wed, Jun 18, 2003 at 04:14:05PM -0700, Tim Howell wrote:
> I have a fairly complicated template that utilizes one <tmpl_loop>, a
> couple of <tmpl_unless>s, and several <tmpl_if><tmpl_else> constructs.
> My problem is that in a certain area of the template any parameter name
> that I enter isn't being recognized, and so (because of die on bad
> params) my script is failing.
>
> I've been over the template several times today, and I'm printing it out
> now so that I can look though it more carefully. If I don't find
> anything obvious, though, where do I go from here?
>
> Thanks! =)
>
> --Tim Howell
I'm guessing here, but it sounds like you're somewhere in the <tmpl_loop> and
global_vars is not set true and you're referencing some value that is not in
the tmpl_loop variable. The following script will fail because xx is not part
of the 'myloop' variable. But if you set global_vars=>1 in the call to new the
error will go away. Alternatively you could add xx to the 'myloop' structure.
#!/usr/bin/perl -w
use strict;
use HTML::Template;
my $tmpl = HTML::Template->new(filehandle => \*DATA, global_vars=>1);
$tmpl->param(
greeting => 'Greetings and Salutations',
myloop => [
{item=>'item 1', selected=>0.},
{item=>'item 2', selected=>0.},
{item=>'item 3', selected=>1.},
{item=>'item 4', selected=>0.},
],
xx => 'is xx',
);
print $tmpl->output;
__DATA__
<html>
<head>
</head>
<body>
<h1><tmpl_var name="greeting"></h1>
<ul>
<tmpl_loop name="myloop">
<li><tmpl_var name="item"></li>
<tmpl_if name="selected"><tmpl_var name="xx"></tmpl_if>
</tmpl_loop>
</ul>
</body>
</html>
Ron
--
Ron Mahoney
Ra Security Systems, Inc.
[EMAIL PROTECTED]
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users