Hello and sorry to bother you with what is likely to be a facile question. But I've read the docs, and browsed the web, though I've not managed to search the archive of this list as I couldn't find an interface.
I've created a simple template to display customer details from a mysql DB, the interesting bit looks like [% FOREACH customer IN DBI.query('SELECT * FROM customers ORDER BY name') %] <tr> <td>[% customer.name %]</td> <td>[% customer.address %]</td> .... </tr> [% END %] Which works lovely. Now the main thing I'll want to do is limit and sort the data shown in this table, so ideally I want a SQL statement like SELECT * FROM customers WHERE $foo = $bar ORDER BY $baz and to be able to set them from the cgi. But I can't get the syntax right, it seems. I've tried [% FOREACH customer IN DBI.query('SELECT * FROM customers ORDER BY [% baz %]') %] and [% query = DBI.prepare('SELECT * FROM customer ORDER BY ?') %] [% FOREACH customer = query.execute('$baz') %] fwiw the perl calling all this looks like #!/usr/bin/perl -Tw use strict; use CGI; # don't reinvent the wheel use Template; my $tt = Template->new({ INCLUDE_PATH => '../templates', INTERPOLATE => 1, }) || die "$Template::ERROR\n"; my $vars = { copyright => 'released under the GPL 2008', baz => 'email' }; $tt->process('ssss', $vars) || die $tt->error(), "\n"; so it is set to INTERPOLATE. So can I nest the Template tags? it would seem not, is there another way to do this? I'm sure this is easy, but if it isn't is my best bet to write a template for the template so I can set my SQL query up at runtime? thanks loads in advance Mik -- GPG key here. http://www.gatrell.org/gpg.public.key
signature.asc
Description: Digital signature
_______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates