nathaniels has asked for the wisdom of the Perl Monks concerning the following question:
Here's the Template:get '/home' => sub { my $db = connect_db(); my $sth = $db->prepare('SELECT ID, FirstName, LastName FROM People +Tbl ORDER BY ID DESC') or die "Couldn't prepare statement: " . $db->errstr; $sth->execute or die $sth->errstr; template 'home.tt', { list => [ 'Tom', 'Dick', 'Larry'], }; };
And here's the config file in case I've gotten something wrong there.<HTML> <TITLE>Home</TITLE> <H1>You're home!</H1> <H2>Here's a list of things:</H2> <BODY> <% FOREACH item IN list %> <LI><% item %></LI> <% END %> </BODY> </HTML>
I know from previous attempts that I can carry over a scalar variable without a hitch but anytime I try to use a FOREACH loop I get nothing. Thanks!#template engine # simple: default and very basic template engine # template_toolkit: TT template: "simple" template: "template_toolkit" # engines: # template_toolkit: # start_tag: '[%' # end_tag: '%]'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dancer and Template-Toolkit
by kcott (Archbishop) on Sep 08, 2013 at 03:18 UTC | |
by tobyink (Canon) on Sep 09, 2013 at 00:24 UTC | |
by nathaniels (Acolyte) on Sep 08, 2013 at 03:40 UTC | |
|
Re: Dancer and Template-Toolkit
by CountZero (Bishop) on Sep 08, 2013 at 19:59 UTC | |
by gsiems (Deacon) on Sep 08, 2013 at 22:15 UTC | |
by kcott (Archbishop) on Sep 09, 2013 at 06:58 UTC |