Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Changing data structure with HTML::Template

by gryphon (Abbot)
on Feb 06, 2014 at 21:04 UTC ( #1073765=note: print w/replies, xml ) Need Help??


in reply to Changing data structure with HTML::Template

Greetings jms53,

I think you'll need to change your data structure. HTML::Template expects to iterate through hashrefs in an array rather than arrayrefs.

$account->{transactions} = [ map { { line => $_ } } @transactions ]; push @transactions, { date => $date, type => $type, amount => $amount, balance => $new_balance };

Replies are listed 'Best First'.
Re^2: Changing data structure with HTML::Template
by jms53 (Monk) on Feb 07, 2014 at 11:51 UTC
    Thank you gryphon,

    I updated my code as you showed, and the page now loads. However, the html sent to the browser doesn't contain any data for the table.

    <table border="1"> <tbody><tr> <td></td><td>Date</td><td>Type</td><td>Amount</td><td>Balance</ +td> </tr> <tr><td>Transaction:</td> </tr> </tbody></table>

    What I'm supposed to be seeing is more something along the lines of :
     <tr><td>Transaction</td><td>2014-02-06</td><td>credit</td><td>400</td><td>1400</td></tr>

    I have debugged the data to confirm it exists (my first project I was deleting my data on the first run, and then all subsequent runs yielded 0 results), and I'm not getting any complaints from the server. If you have any ideas, they are most welcome :)

    J -

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1073765]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2020-10-29 13:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (271 votes). Check out past polls.

    Notices?