RE: [Templates] Why can't I create a list of named hashes?
[prev]
[thread]
[next]
[Date index for 2004/11/18]
I believe the "$" preceding "mod_menu" is only needed during string =
interpolation. Try this instead (note I also added semicolons to =
terminate each template directive as not doing so would have caused an =
additional error):
## start code
use strict;
use warnings;
use Template;
my $template =3D new Template;
$template->process (\*DATA) or die $template->error;
exit;
__DATA__
[%=20
SET mod_menu =3D
{
title=3D> "Title",
html=3D> "Html text"
};
=20
SET right_modules =3D [
mod_menu
];
%]
[% FOREACH module =3D right_modules %]
[% module.title %]
[% module.html %]
[% END %] =20
## end code
-----Original Message-----
From: templates-admin@xxxxxxxxxxxxxxxx.xxx
[mailto:templates-admin@xxxxxxxxxxxxxxxx.xxx]On Behalf Of Jason Peck
Sent: Thursday, November 18, 2004 10:09 AM
To: templates@xxxxxxxxxxxxxxxx.xxx
Subject: [Templates] Why can't I create a list of named hashes?
Can someone help me figure out how to create a named hash, then include
it in a named list within a template? I can't understand why the
following does not work:
[%=20
mod_menu =3D
{
title=3D> "Title",
html=3D> "Html text"
}
=20
right_modules =3D [
$mod_menu
]
%]
[% FOREACH module =3D right_modules %]
[% module.title %]
[% module.html %]
[% END %] =20
It produces an error:
! undef error - Template::Stash::XS: get (arg 2) must be a scalar or
listref
I also tried using \$mod_menu. In that case, I don't get an error but
nothing is printed.
--=20
Jason Peck
Focus Robotics
Tel. 603.594.3097
http://www.focusrobotics.com
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
 |
RE: [Templates] Why can't I create a list of named hashes?
Peter Guzis 18:18 on 18 Nov 2004
|