<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">You don't show what your tests render<div class=""><br class=""></div><div class="">Like in perl Dumper is your friend</div><div class=""><br class=""></div><div class=""><a href="http://www.template-toolkit.org/docs/modules/Template/Plugin/Dumper.html" class="">http://www.template-toolkit.org/docs/modules/Template/Plugin/Dumper.html</a></div><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">— <br class="">Clive Eisen<br class="">GPG: 3818B5F1<br class=""><br class=""><br class=""><br class=""><br class=""><br class=""></div></div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On 22 Aug 2020, at 22:32, Richard Reina <<a href="mailto:gatorreina@gmail.com" class="">gatorreina@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I have the following perl multidimensional hash that is passed from<br class="">Dancer to Template Toolkit as a hash reference. I am having trouble<br class="">figuring out how to display it in Template Toolkit.<br class=""><br class="">$VAR1 = {<br class=""> 'TylerMontgomery(2022)' => {<br class=""> 'so' => 1,<br class=""> 'bb' => 1,<br class=""> 'rbis' => 0,<br class=""> 'atbats' => 7,<br class=""> 'runs' => 2,<br class=""> 'hits' => 2<br class=""> },<br class=""> 'ChaseLangan(2022)' => {<br class=""> 'runs' => 4,<br class=""> 'hits' => 4,<br class=""> 'atbats' => 5,<br class=""> 'bb' => 0,<br class=""> 'rbis' => 2,<br class=""> 'so' => 1<br class=""> },<br class=""> 'BryceJones(2021)' => {<br class=""> 'hits' => 2,<br class=""> 'runs' => 2,<br class=""> 'atbats' => 4,<br class=""> 'bb' => 1,<br class=""> 'rbis' => 4,<br class=""> 'so' => 1<br class=""> },<br class="">};<br class=""><br class="">This is how I iterate it in perl.<br class=""><br class="">foreach my $name (sort keys %season) {<br class=""> printf "%-27.27s", "$name: ";<br class=""> foreach my $stat (sort keys %{ $season{$name} }) {<br class=""> printf "%-12.12s", "$stat: $season{$name}{$stat} ";<br class=""> ## cal. avg<br class=""> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats};<br class=""> }<br class=""><br class=""><br class=""> printf "%4s %.3f\n", "avg:", $season{$name}{AVG};<br class="">}<br class=""><br class="">I then pass it back to my dancer app as a ref. with return \%season;<br class="">and then to template toolkit with:<br class=""><br class=""> template 'softball.tt' => {<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>'title' => 'Get Softball Season Stats',<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>'Season' => $season,<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><br class=""> }, {};<br class=""><br class="">But I am lost trying to get it to display with template toolkit.<br class="">Here's what I've tried so far.<br class=""><br class=""><table style="width:100%; line-height:40px;"><br class=""> <% FOREACH Season = Season %><br class=""> <tr><br class=""> <td width="5">Season.key <% Season.key %></td><br class=""> <td width="5">Season.val <% Season.value %></td><br class=""> <td width="5">Season.val.atbats <% Season.value.atbats %><br class=""> <td width="5">Season.val.hits <% Season.value.hits %><br class=""> </tr><br class=""> <% END %><br class=""><br class="">Thanks for any help.<br class="">_______________________________________________<br class="">dancer-users mailing list<br class=""><a href="mailto:dancer-users@lists.preshweb.co.uk" class="">dancer-users@lists.preshweb.co.uk</a><br class="">https://lists.preshweb.co.uk/mailman/listinfo/dancer-users<br class=""></div></div></blockquote></div><br class=""></div></body></html>