mikeraz has asked for the wisdom of the Perl Monks concerning the following question:
Update to Update: Life would have been much easier if I'd read the Template VMethods documentation. If you're having problems: STOP, go there, read.
Update: Figured it out, OQ and solution follow. Editorial comments on the Perl and TT would be welcome.
my head hurts. I'm having a serious grok failure in working with Template
Given this Data::Dumper output from within my .tt2 file what would be the TT syntax for access/printing the name and dates from ab and ac?
Update: Figured it out (many thanks to Date::Dumper!)$VAR1 = { '20120317' => { 'sort_date' => 20120317, 'file_base' => 'Brew_Pub_Populaire', 'stoker' => 'Tom Organizer', 'date' => 'March 17', 'name' => 'Brew Pub Populaire', 'dist' => '100', 'email' => 'otherrider@example.com', 'cred' => 'RUSA', 'start' => 'Cornelius Pass Roadhouse' }, '20120331' => { 'sort_date' => 20120331, 'file_base' => 'Molalla_Foothills', 'stoker' => 'Michael Fastrider', 'date' => 'March 31', 'name' => 'Molalla Foothills', 'dist' => '200', 'email' => 'cyclo@example.com', 'cred' => 'ACP', 'start' => 'Canby, OR' } };
[% FOREACH brevet = brevets %] brevet.key [% brevet.key %] brevet.val [% brevet.value %] brevet.val.name [% brevet.value.name %] brevet.val.date [% brevet.value.date %] brevet.val.dist [% brevet.value.dist %] brevet.val.start [% brevet.value.start %] brevet.val.stoker [% brevet.value.stoker %] [% END %]
For the curious, the Perl that calls TT is something like:
my %tt_food; foreach my $key ( sort { $brevet_config{$a}{sort_date} <=> $brevet_con +fig{$b}{sort_date} } keys %brevet_config ) { $tt_food{$brevet_config{$key}{sort_date}} = $brevet_config{$key}; } my $vars = { brevets => \%tt_food, }; $template->process( 'schedule.tt2', $vars ) or die $template->error();
note: Several updates as I worked through it.
|
|---|