packetstormer has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks
I have an output problem within Template. The hash below is being passed to the template file I am simply trying to format it before displaying it. The problem is it seems to being displaying very oddly and I can't figure out why.
# Hash being passed from pl file as %results $VAR1 = { 'Local Studies' => [ { 'closed' => '53' }, { 'open' => '13' } ], 'Local History' => [ { 'open' => '1' }, { 'closed' => '4' } ], 'Reference Dept' => [ { 'open' => '1' }, { 'closed' => '2' } ], 'Admin' => [ { 'open' => '1' } ] };
The template code is below (the idea is a simple table output):
[% USE Dumper %] [% Dumper.dump(results) %] <table border="1"> [% FOREACH key IN results.keys.sort %] <tr> <td>[% key %]</td> <td>[% results.$key.0.open %]</td> <td>[% results.$key.1.closed %]</td> </tr> [% END %] </table>
However the actual output page looks like this:
<tr> <td>Admin</td> <td>1</td> <td></td> </tr> <tr> <td>Local History</td> <td>1</td> <td>4</td> </tr> <tr> <td>Local Studies</td> <td></td> <td></td> </tr> <tr> <td>Reference Dept</td> <td>1</td> <td>2</td> </tr>
Can anyone see why the template is missing the value for the "Local Studies" section? I've been looking at this for a while so I hope it is something silly I am over looking!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Template display?
by dasgar (Priest) on Jun 20, 2012 at 13:56 UTC | |
|
Re: Template display?
by toolic (Bishop) on Jun 20, 2012 at 13:26 UTC | |
|
Re: Template display?
by Anonymous Monk on Jun 20, 2012 at 13:26 UTC | |
by Anonymous Monk on Jun 20, 2012 at 13:49 UTC |