[Templates] Variable interpolation question
Dennis Daupert
ddaupert@csc.com
Tue, 3 Sep 2002 09:26:34 -0500
Hi folks, I have been lurking for a little while, and
have been impressed with the friendly, helpful
atmosphere on this news group. I have a few questions,
and will bravely wade on in with one (for now).
I recently installed Template Toolkit () and haven't
quite gotten the hang of how to pass variables into a
template in some circumstances.
For example, I need to create a popup menu dropdown
dynamically populated by a list of users pulled from a
database. So I pull my list into an array referenced by
$users_ref, stick $users_ref into my global hash...
my %globals = (
user => $r->user,
users => "$users_ref"
);
my $template = Template->new({
INCLUDE_PATH => '/usr/local/apache/tt2:/usr/local/apache/tt2/templates',
VARIABLES => \%globals,
PROCESS => 'standard.tmpl',
});
and then tried this:
[% USE CGI %]
<b>Assign To:</b> [% CGI.popup_menu("assignee", [% $users_ref %]) %]
and he bombs out. Obviously I can't nest the
interpolation signs -- [% %] -- but what should I use
instead when I have a var that needs to be interpolated
into a context which itself is interpolated?
/dennis