From gatorreina at gmail.com Sat Aug 22 17:32:53 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sat, 22 Aug 2020 16:32:53 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit Message-ID: I have the following perl multidimensional hash that is passed from Dancer to Template Toolkit as a hash reference. I am having trouble figuring out how to display it in Template Toolkit. $VAR1 = { 'TylerMontgomery(2022)' => { 'so' => 1, 'bb' => 1, 'rbis' => 0, 'atbats' => 7, 'runs' => 2, 'hits' => 2 }, 'ChaseLangan(2022)' => { 'runs' => 4, 'hits' => 4, 'atbats' => 5, 'bb' => 0, 'rbis' => 2, 'so' => 1 }, 'BryceJones(2021)' => { 'hits' => 2, 'runs' => 2, 'atbats' => 4, 'bb' => 1, 'rbis' => 4, 'so' => 1 }, }; This is how I iterate it in perl. foreach my $name (sort keys %season) { printf "%-27.27s", "$name: "; foreach my $stat (sort keys %{ $season{$name} }) { printf "%-12.12s", "$stat: $season{$name}{$stat} "; ## cal. avg $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; } printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; } I then pass it back to my dancer app as a ref. with return \%season; and then to template toolkit with: template 'softball.tt' => { 'title' => 'Get Softball Season Stats', 'Season' => $season, }, {}; But I am lost trying to get it to display with template toolkit. Here's what I've tried so far. <% FOREACH Season = Season %> <% END %> Thanks for any help. From clive at hildebrand.co.uk Sun Aug 23 06:33:47 2020 From: clive at hildebrand.co.uk (Clive Eisen) Date: Sun, 23 Aug 2020 11:33:47 +0100 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: <33EC8705-24FC-4677-BAE2-1C9E140353CC@hildebrand.co.uk> You don't show what your tests render Like in perl Dumper is your friend http://www.template-toolkit.org/docs/modules/Template/Plugin/Dumper.html ? Clive Eisen GPG: 3818B5F1 > On 22 Aug 2020, at 22:32, Richard Reina wrote: > > I have the following perl multidimensional hash that is passed from > Dancer to Template Toolkit as a hash reference. I am having trouble > figuring out how to display it in Template Toolkit. > > $VAR1 = { > 'TylerMontgomery(2022)' => { > 'so' => 1, > 'bb' => 1, > 'rbis' => 0, > 'atbats' => 7, > 'runs' => 2, > 'hits' => 2 > }, > 'ChaseLangan(2022)' => { > 'runs' => 4, > 'hits' => 4, > 'atbats' => 5, > 'bb' => 0, > 'rbis' => 2, > 'so' => 1 > }, > 'BryceJones(2021)' => { > 'hits' => 2, > 'runs' => 2, > 'atbats' => 4, > 'bb' => 1, > 'rbis' => 4, > 'so' => 1 > }, > }; > > This is how I iterate it in perl. > > foreach my $name (sort keys %season) { > printf "%-27.27s", "$name: "; > foreach my $stat (sort keys %{ $season{$name} }) { > printf "%-12.12s", "$stat: $season{$name}{$stat} "; > ## cal. avg > $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; > } > > > printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; > } > > I then pass it back to my dancer app as a ref. with return \%season; > and then to template toolkit with: > > template 'softball.tt' => { > > 'title' => 'Get Softball Season Stats', > 'Season' => $season, > > > }, {}; > > But I am lost trying to get it to display with template toolkit. > Here's what I've tried so far. > >
Season.key <% Season.key %> Season.val <% Season.value %> Season.val.atbats <% Season.value.atbats %> Season.val.hits <% Season.value.hits %>
> <% FOREACH Season = Season %> > > > > > <% END %> > > Thanks for any help. > _______________________________________________ > dancer-users mailing list > dancer-users at lists.preshweb.co.uk > https://lists.preshweb.co.uk/mailman/listinfo/dancer-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Sun Aug 23 08:18:34 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Sun, 23 Aug 2020 15:18:34 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: I am not sure if this is what you meant, but using your data I wrote two examples here: https://perlmaven.com/template-toolkit-hash-of-hash Gabor On Sun, Aug 23, 2020 at 12:33 AM Richard Reina wrote: > I have the following perl multidimensional hash that is passed from > Dancer to Template Toolkit as a hash reference. I am having trouble > figuring out how to display it in Template Toolkit. > > $VAR1 = { > 'TylerMontgomery(2022)' => { > 'so' => 1, > 'bb' => 1, > 'rbis' => 0, > 'atbats' => 7, > 'runs' => 2, > 'hits' => 2 > }, > 'ChaseLangan(2022)' => { > 'runs' => 4, > 'hits' => 4, > 'atbats' => 5, > 'bb' => 0, > 'rbis' => 2, > 'so' => 1 > }, > 'BryceJones(2021)' => { > 'hits' => 2, > 'runs' => 2, > 'atbats' => 4, > 'bb' => 1, > 'rbis' => 4, > 'so' => 1 > }, > }; > > This is how I iterate it in perl. > > foreach my $name (sort keys %season) { > printf "%-27.27s", "$name: "; > foreach my $stat (sort keys %{ $season{$name} }) { > printf "%-12.12s", "$stat: $season{$name}{$stat} "; > ## cal. avg > $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; > } > > > printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; > } > > I then pass it back to my dancer app as a ref. with return \%season; > and then to template toolkit with: > > template 'softball.tt' => { > > 'title' => 'Get Softball Season Stats', > 'Season' => $season, > > > }, {}; > > But I am lost trying to get it to display with template toolkit. > Here's what I've tried so far. > >
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> > Season.val.hits <% Season.value.hits %> >
> <% FOREACH Season = Season %> > > > > > <% END %> > > Thanks for any help. > _______________________________________________ > dancer-users mailing list > dancer-users at lists.preshweb.co.uk > https://lists.preshweb.co.uk/mailman/listinfo/dancer-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Sun Aug 23 08:18:34 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Sun, 23 Aug 2020 15:18:34 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: I am not sure if this is what you meant, but using your data I wrote two examples here: https://perlmaven.com/template-toolkit-hash-of-hash Gabor On Sun, Aug 23, 2020 at 12:33 AM Richard Reina wrote: > I have the following perl multidimensional hash that is passed from > Dancer to Template Toolkit as a hash reference. I am having trouble > figuring out how to display it in Template Toolkit. > > $VAR1 = { > 'TylerMontgomery(2022)' => { > 'so' => 1, > 'bb' => 1, > 'rbis' => 0, > 'atbats' => 7, > 'runs' => 2, > 'hits' => 2 > }, > 'ChaseLangan(2022)' => { > 'runs' => 4, > 'hits' => 4, > 'atbats' => 5, > 'bb' => 0, > 'rbis' => 2, > 'so' => 1 > }, > 'BryceJones(2021)' => { > 'hits' => 2, > 'runs' => 2, > 'atbats' => 4, > 'bb' => 1, > 'rbis' => 4, > 'so' => 1 > }, > }; > > This is how I iterate it in perl. > > foreach my $name (sort keys %season) { > printf "%-27.27s", "$name: "; > foreach my $stat (sort keys %{ $season{$name} }) { > printf "%-12.12s", "$stat: $season{$name}{$stat} "; > ## cal. avg > $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; > } > > > printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; > } > > I then pass it back to my dancer app as a ref. with return \%season; > and then to template toolkit with: > > template 'softball.tt' => { > > 'title' => 'Get Softball Season Stats', > 'Season' => $season, > > > }, {}; > > But I am lost trying to get it to display with template toolkit. > Here's what I've tried so far. > >
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> > Season.val.hits <% Season.value.hits %> >
> <% FOREACH Season = Season %> > > > > > <% END %> > > Thanks for any help. > _______________________________________________ > dancer-users mailing list > dancer-users at lists.preshweb.co.uk > https://lists.preshweb.co.uk/mailman/listinfo/dancer-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gatorreina at gmail.com Sun Aug 23 10:46:02 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sun, 23 Aug 2020 09:46:02 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: Hi Gabor, Thank you very much for your help. I appreciate your answer and all the wonderful tutorials at perlmaven, but so far I am unable to get this answer to work for me. My my hash %season seems to look the same as your %payload but when I try your solution only the name of the player is displayed. I do not use 'use Template'; in my backend code and am not really sure what the exact role of create.pl, is it for teaching purposes or is there a step within it that I must apply to get my %season to look like your %payload before I return it to my Dancer app? I will continue to experiment with your solution and try to find a place where I can post exactly what I am getting as a result. Thanks again, Richard 2020-08-23 7:18 GMT-05:00, Gabor Szabo : > I am not sure if this is what you meant, but using your data I wrote two > examples here: https://perlmaven.com/template-toolkit-hash-of-hash > > Gabor > > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina > wrote: > >> I have the following perl multidimensional hash that is passed from >> Dancer to Template Toolkit as a hash reference. I am having trouble >> figuring out how to display it in Template Toolkit. >> >> $VAR1 = { >> 'TylerMontgomery(2022)' => { >> 'so' => 1, >> 'bb' => 1, >> 'rbis' => 0, >> 'atbats' => 7, >> 'runs' => 2, >> 'hits' => 2 >> }, >> 'ChaseLangan(2022)' => { >> 'runs' => 4, >> 'hits' => 4, >> 'atbats' => 5, >> 'bb' => 0, >> 'rbis' => 2, >> 'so' => 1 >> }, >> 'BryceJones(2021)' => { >> 'hits' => 2, >> 'runs' => 2, >> 'atbats' => 4, >> 'bb' => 1, >> 'rbis' => 4, >> 'so' => 1 >> }, >> }; >> >> This is how I iterate it in perl. >> >> foreach my $name (sort keys %season) { >> printf "%-27.27s", "$name: "; >> foreach my $stat (sort keys %{ $season{$name} }) { >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> ## cal. avg >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; >> } >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> } >> >> I then pass it back to my dancer app as a ref. with return \%season; >> and then to template toolkit with: >> >> template 'softball.tt' => { >> >> 'title' => 'Get Softball Season Stats', >> 'Season' => $season, >> >> >> }, {}; >> >> But I am lost trying to get it to display with template toolkit. >> Here's what I've tried so far. >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> > Season.val.hits <% Season.value.hits %> >
>> <% FOREACH Season = Season %> >> >> >> >> >> <% END %> >> >> Thanks for any help. >> _______________________________________________ >> dancer-users mailing list >> dancer-users at lists.preshweb.co.uk >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> > From gatorreina at gmail.com Sun Aug 23 10:46:02 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sun, 23 Aug 2020 09:46:02 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: Hi Gabor, Thank you very much for your help. I appreciate your answer and all the wonderful tutorials at perlmaven, but so far I am unable to get this answer to work for me. My my hash %season seems to look the same as your %payload but when I try your solution only the name of the player is displayed. I do not use 'use Template'; in my backend code and am not really sure what the exact role of create.pl, is it for teaching purposes or is there a step within it that I must apply to get my %season to look like your %payload before I return it to my Dancer app? I will continue to experiment with your solution and try to find a place where I can post exactly what I am getting as a result. Thanks again, Richard 2020-08-23 7:18 GMT-05:00, Gabor Szabo : > I am not sure if this is what you meant, but using your data I wrote two > examples here: https://perlmaven.com/template-toolkit-hash-of-hash > > Gabor > > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina > wrote: > >> I have the following perl multidimensional hash that is passed from >> Dancer to Template Toolkit as a hash reference. I am having trouble >> figuring out how to display it in Template Toolkit. >> >> $VAR1 = { >> 'TylerMontgomery(2022)' => { >> 'so' => 1, >> 'bb' => 1, >> 'rbis' => 0, >> 'atbats' => 7, >> 'runs' => 2, >> 'hits' => 2 >> }, >> 'ChaseLangan(2022)' => { >> 'runs' => 4, >> 'hits' => 4, >> 'atbats' => 5, >> 'bb' => 0, >> 'rbis' => 2, >> 'so' => 1 >> }, >> 'BryceJones(2021)' => { >> 'hits' => 2, >> 'runs' => 2, >> 'atbats' => 4, >> 'bb' => 1, >> 'rbis' => 4, >> 'so' => 1 >> }, >> }; >> >> This is how I iterate it in perl. >> >> foreach my $name (sort keys %season) { >> printf "%-27.27s", "$name: "; >> foreach my $stat (sort keys %{ $season{$name} }) { >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> ## cal. avg >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; >> } >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> } >> >> I then pass it back to my dancer app as a ref. with return \%season; >> and then to template toolkit with: >> >> template 'softball.tt' => { >> >> 'title' => 'Get Softball Season Stats', >> 'Season' => $season, >> >> >> }, {}; >> >> But I am lost trying to get it to display with template toolkit. >> Here's what I've tried so far. >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> >> Season.val.hits <% Season.value.hits %> >>
>> <% FOREACH Season = Season %> >> >> >> >> >> <% END %> >> >> Thanks for any help. >> _______________________________________________ >> dancer-users mailing list >> dancer-users at lists.preshweb.co.uk >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> > From gabor at szabgab.com Sun Aug 23 10:57:44 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Sun, 23 Aug 2020 17:57:44 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: Have you checked the content when you "view source" in the browser? I had cases when my code did not show up because I had some HTML issues. I wasted so much time till I figured out the content is there just hidden. My example is stand-alone using Template::Toolkit, when using Dancer you don't need that, you only need to enable it in the config file and you pass your data to the "template" function. The TT part is almost identical though I think in Dancer we use <% for tags and not the default [% as in my example. Gabor On Sun, Aug 23, 2020 at 5:46 PM Richard Reina wrote: > Hi Gabor, > > Thank you very much for your help. I appreciate your answer and all > the wonderful tutorials at perlmaven, but so far I am unable to get > this answer to work for me. My my hash %season seems to look the same > as your %payload but when I try your solution only the name of the > player is displayed. I do not use 'use Template'; in my backend code > and am not really sure what the exact role of create.pl, is it for > teaching purposes or is there a step within it that I must apply to > get my %season to look like your %payload before I return it to my > Dancer app? I will continue to experiment with your solution and try > to find a place where I can post exactly what I am getting as a > result. > > Thanks again, > > Richard > > 2020-08-23 7:18 GMT-05:00, Gabor Szabo : > > I am not sure if this is what you meant, but using your data I wrote two > > examples here: https://perlmaven.com/template-toolkit-hash-of-hash > > > > Gabor > > > > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina > > wrote: > > > >> I have the following perl multidimensional hash that is passed from > >> Dancer to Template Toolkit as a hash reference. I am having trouble > >> figuring out how to display it in Template Toolkit. > >> > >> $VAR1 = { > >> 'TylerMontgomery(2022)' => { > >> 'so' => 1, > >> 'bb' => 1, > >> 'rbis' => 0, > >> 'atbats' => 7, > >> 'runs' => 2, > >> 'hits' => 2 > >> }, > >> 'ChaseLangan(2022)' => { > >> 'runs' => 4, > >> 'hits' => 4, > >> 'atbats' => 5, > >> 'bb' => 0, > >> 'rbis' => 2, > >> 'so' => 1 > >> }, > >> 'BryceJones(2021)' => { > >> 'hits' => 2, > >> 'runs' => 2, > >> 'atbats' => 4, > >> 'bb' => 1, > >> 'rbis' => 4, > >> 'so' => 1 > >> }, > >> }; > >> > >> This is how I iterate it in perl. > >> > >> foreach my $name (sort keys %season) { > >> printf "%-27.27s", "$name: "; > >> foreach my $stat (sort keys %{ $season{$name} }) { > >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; > >> ## cal. avg > >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; > >> } > >> > >> > >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; > >> } > >> > >> I then pass it back to my dancer app as a ref. with return \%season; > >> and then to template toolkit with: > >> > >> template 'softball.tt' => { > >> > >> 'title' => 'Get Softball Season Stats', > >> 'Season' => $season, > >> > >> > >> }, {}; > >> > >> But I am lost trying to get it to display with template toolkit. > >> Here's what I've tried so far. > >> > >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> >> Season.val.hits <% Season.value.hits %> >>
> >> <% FOREACH Season = Season %> > >> > >> > >> > >> > >> <% END %> > >> > >> Thanks for any help. > >> _______________________________________________ > >> dancer-users mailing list > >> dancer-users at lists.preshweb.co.uk > >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users > >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Sun Aug 23 10:57:44 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Sun, 23 Aug 2020 17:57:44 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: Have you checked the content when you "view source" in the browser? I had cases when my code did not show up because I had some HTML issues. I wasted so much time till I figured out the content is there just hidden. My example is stand-alone using Template::Toolkit, when using Dancer you don't need that, you only need to enable it in the config file and you pass your data to the "template" function. The TT part is almost identical though I think in Dancer we use <% for tags and not the default [% as in my example. Gabor On Sun, Aug 23, 2020 at 5:46 PM Richard Reina wrote: > Hi Gabor, > > Thank you very much for your help. I appreciate your answer and all > the wonderful tutorials at perlmaven, but so far I am unable to get > this answer to work for me. My my hash %season seems to look the same > as your %payload but when I try your solution only the name of the > player is displayed. I do not use 'use Template'; in my backend code > and am not really sure what the exact role of create.pl, is it for > teaching purposes or is there a step within it that I must apply to > get my %season to look like your %payload before I return it to my > Dancer app? I will continue to experiment with your solution and try > to find a place where I can post exactly what I am getting as a > result. > > Thanks again, > > Richard > > 2020-08-23 7:18 GMT-05:00, Gabor Szabo : > > I am not sure if this is what you meant, but using your data I wrote two > > examples here: https://perlmaven.com/template-toolkit-hash-of-hash > > > > Gabor > > > > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina > > wrote: > > > >> I have the following perl multidimensional hash that is passed from > >> Dancer to Template Toolkit as a hash reference. I am having trouble > >> figuring out how to display it in Template Toolkit. > >> > >> $VAR1 = { > >> 'TylerMontgomery(2022)' => { > >> 'so' => 1, > >> 'bb' => 1, > >> 'rbis' => 0, > >> 'atbats' => 7, > >> 'runs' => 2, > >> 'hits' => 2 > >> }, > >> 'ChaseLangan(2022)' => { > >> 'runs' => 4, > >> 'hits' => 4, > >> 'atbats' => 5, > >> 'bb' => 0, > >> 'rbis' => 2, > >> 'so' => 1 > >> }, > >> 'BryceJones(2021)' => { > >> 'hits' => 2, > >> 'runs' => 2, > >> 'atbats' => 4, > >> 'bb' => 1, > >> 'rbis' => 4, > >> 'so' => 1 > >> }, > >> }; > >> > >> This is how I iterate it in perl. > >> > >> foreach my $name (sort keys %season) { > >> printf "%-27.27s", "$name: "; > >> foreach my $stat (sort keys %{ $season{$name} }) { > >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; > >> ## cal. avg > >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; > >> } > >> > >> > >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; > >> } > >> > >> I then pass it back to my dancer app as a ref. with return \%season; > >> and then to template toolkit with: > >> > >> template 'softball.tt' => { > >> > >> 'title' => 'Get Softball Season Stats', > >> 'Season' => $season, > >> > >> > >> }, {}; > >> > >> But I am lost trying to get it to display with template toolkit. > >> Here's what I've tried so far. > >> > >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> > >> Season.val.hits <% Season.value.hits %> > >>
> >> <% FOREACH Season = Season %> > >> > >> > >> > >> > >> <% END %> > >> > >> Thanks for any help. > >> _______________________________________________ > >> dancer-users mailing list > >> dancer-users at lists.preshweb.co.uk > >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users > >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Sun Aug 23 11:53:42 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Sun, 23 Aug 2020 18:53:42 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: In the meantime I wrote an example using Dancer as well, though I used a different dataset: https://code-maven.com/slides/perl/showing-hash-of-hashes regards Gabor On Sun, Aug 23, 2020 at 5:57 PM Gabor Szabo wrote: > Have you checked the content when you "view source" in the browser? > I had cases when my code did not show up because I had some HTML issues. > I wasted so much time till I figured out the content is there just hidden. > > My example is stand-alone using Template::Toolkit, > when using Dancer you don't need that, you only need to enable it in the > config file > and you pass your data to the "template" function. > > The TT part is almost identical though I think in Dancer we use <% for > tags and not > the default [% as in my example. > > Gabor > > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina > wrote: > >> Hi Gabor, >> >> Thank you very much for your help. I appreciate your answer and all >> the wonderful tutorials at perlmaven, but so far I am unable to get >> this answer to work for me. My my hash %season seems to look the same >> as your %payload but when I try your solution only the name of the >> player is displayed. I do not use 'use Template'; in my backend code >> and am not really sure what the exact role of create.pl, is it for >> teaching purposes or is there a step within it that I must apply to >> get my %season to look like your %payload before I return it to my >> Dancer app? I will continue to experiment with your solution and try >> to find a place where I can post exactly what I am getting as a >> result. >> >> Thanks again, >> >> Richard >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : >> > I am not sure if this is what you meant, but using your data I wrote two >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash >> > >> > Gabor >> > >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina >> > wrote: >> > >> >> I have the following perl multidimensional hash that is passed from >> >> Dancer to Template Toolkit as a hash reference. I am having trouble >> >> figuring out how to display it in Template Toolkit. >> >> >> >> $VAR1 = { >> >> 'TylerMontgomery(2022)' => { >> >> 'so' => 1, >> >> 'bb' => 1, >> >> 'rbis' => 0, >> >> 'atbats' => 7, >> >> 'runs' => 2, >> >> 'hits' => 2 >> >> }, >> >> 'ChaseLangan(2022)' => { >> >> 'runs' => 4, >> >> 'hits' => 4, >> >> 'atbats' => 5, >> >> 'bb' => 0, >> >> 'rbis' => 2, >> >> 'so' => 1 >> >> }, >> >> 'BryceJones(2021)' => { >> >> 'hits' => 2, >> >> 'runs' => 2, >> >> 'atbats' => 4, >> >> 'bb' => 1, >> >> 'rbis' => 4, >> >> 'so' => 1 >> >> }, >> >> }; >> >> >> >> This is how I iterate it in perl. >> >> >> >> foreach my $name (sort keys %season) { >> >> printf "%-27.27s", "$name: "; >> >> foreach my $stat (sort keys %{ $season{$name} }) { >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> >> ## cal. avg >> >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; >> >> } >> >> >> >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> >> } >> >> >> >> I then pass it back to my dancer app as a ref. with return \%season; >> >> and then to template toolkit with: >> >> >> >> template 'softball.tt' => { >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> 'Season' => $season, >> >> >> >> >> >> }, {}; >> >> >> >> But I am lost trying to get it to display with template toolkit. >> >> Here's what I've tried so far. >> >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> > >> Season.val.hits <% Season.value.hits %> > >>
>> >> <% FOREACH Season = Season %> >> >> >> >> >> >> >> >> >> >> <% END %> >> >> >> >> Thanks for any help. >> >> _______________________________________________ >> >> dancer-users mailing list >> >> dancer-users at lists.preshweb.co.uk >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> > >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Sun Aug 23 11:53:42 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Sun, 23 Aug 2020 18:53:42 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: In the meantime I wrote an example using Dancer as well, though I used a different dataset: https://code-maven.com/slides/perl/showing-hash-of-hashes regards Gabor On Sun, Aug 23, 2020 at 5:57 PM Gabor Szabo wrote: > Have you checked the content when you "view source" in the browser? > I had cases when my code did not show up because I had some HTML issues. > I wasted so much time till I figured out the content is there just hidden. > > My example is stand-alone using Template::Toolkit, > when using Dancer you don't need that, you only need to enable it in the > config file > and you pass your data to the "template" function. > > The TT part is almost identical though I think in Dancer we use <% for > tags and not > the default [% as in my example. > > Gabor > > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina > wrote: > >> Hi Gabor, >> >> Thank you very much for your help. I appreciate your answer and all >> the wonderful tutorials at perlmaven, but so far I am unable to get >> this answer to work for me. My my hash %season seems to look the same >> as your %payload but when I try your solution only the name of the >> player is displayed. I do not use 'use Template'; in my backend code >> and am not really sure what the exact role of create.pl, is it for >> teaching purposes or is there a step within it that I must apply to >> get my %season to look like your %payload before I return it to my >> Dancer app? I will continue to experiment with your solution and try >> to find a place where I can post exactly what I am getting as a >> result. >> >> Thanks again, >> >> Richard >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : >> > I am not sure if this is what you meant, but using your data I wrote two >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash >> > >> > Gabor >> > >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina >> > wrote: >> > >> >> I have the following perl multidimensional hash that is passed from >> >> Dancer to Template Toolkit as a hash reference. I am having trouble >> >> figuring out how to display it in Template Toolkit. >> >> >> >> $VAR1 = { >> >> 'TylerMontgomery(2022)' => { >> >> 'so' => 1, >> >> 'bb' => 1, >> >> 'rbis' => 0, >> >> 'atbats' => 7, >> >> 'runs' => 2, >> >> 'hits' => 2 >> >> }, >> >> 'ChaseLangan(2022)' => { >> >> 'runs' => 4, >> >> 'hits' => 4, >> >> 'atbats' => 5, >> >> 'bb' => 0, >> >> 'rbis' => 2, >> >> 'so' => 1 >> >> }, >> >> 'BryceJones(2021)' => { >> >> 'hits' => 2, >> >> 'runs' => 2, >> >> 'atbats' => 4, >> >> 'bb' => 1, >> >> 'rbis' => 4, >> >> 'so' => 1 >> >> }, >> >> }; >> >> >> >> This is how I iterate it in perl. >> >> >> >> foreach my $name (sort keys %season) { >> >> printf "%-27.27s", "$name: "; >> >> foreach my $stat (sort keys %{ $season{$name} }) { >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> >> ## cal. avg >> >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; >> >> } >> >> >> >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> >> } >> >> >> >> I then pass it back to my dancer app as a ref. with return \%season; >> >> and then to template toolkit with: >> >> >> >> template 'softball.tt' => { >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> 'Season' => $season, >> >> >> >> >> >> }, {}; >> >> >> >> But I am lost trying to get it to display with template toolkit. >> >> Here's what I've tried so far. >> >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> >> >> Season.val.hits <% Season.value.hits %> >> >>
>> >> <% FOREACH Season = Season %> >> >> >> >> >> >> >> >> >> >> <% END %> >> >> >> >> Thanks for any help. >> >> _______________________________________________ >> >> dancer-users mailing list >> >> dancer-users at lists.preshweb.co.uk >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> > >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gatorreina at gmail.com Sun Aug 23 12:21:56 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sun, 23 Aug 2020 11:21:56 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: I am beginning to suspect my html code as well. Will try to simplify and report back. Thanks, again 2020-08-23 9:57 GMT-05:00, Gabor Szabo : > Have you checked the content when you "view source" in the browser? > I had cases when my code did not show up because I had some HTML issues. > I wasted so much time till I figured out the content is there just hidden. > > My example is stand-alone using Template::Toolkit, > when using Dancer you don't need that, you only need to enable it in the > config file > and you pass your data to the "template" function. > > The TT part is almost identical though I think in Dancer we use <% for tags > and not > the default [% as in my example. > > Gabor > > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina wrote: > >> Hi Gabor, >> >> Thank you very much for your help. I appreciate your answer and all >> the wonderful tutorials at perlmaven, but so far I am unable to get >> this answer to work for me. My my hash %season seems to look the same >> as your %payload but when I try your solution only the name of the >> player is displayed. I do not use 'use Template'; in my backend code >> and am not really sure what the exact role of create.pl, is it for >> teaching purposes or is there a step within it that I must apply to >> get my %season to look like your %payload before I return it to my >> Dancer app? I will continue to experiment with your solution and try >> to find a place where I can post exactly what I am getting as a >> result. >> >> Thanks again, >> >> Richard >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : >> > I am not sure if this is what you meant, but using your data I wrote >> > two >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash >> > >> > Gabor >> > >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina >> > wrote: >> > >> >> I have the following perl multidimensional hash that is passed from >> >> Dancer to Template Toolkit as a hash reference. I am having trouble >> >> figuring out how to display it in Template Toolkit. >> >> >> >> $VAR1 = { >> >> 'TylerMontgomery(2022)' => { >> >> 'so' => 1, >> >> 'bb' => 1, >> >> 'rbis' => 0, >> >> 'atbats' => 7, >> >> 'runs' => 2, >> >> 'hits' => 2 >> >> }, >> >> 'ChaseLangan(2022)' => { >> >> 'runs' => 4, >> >> 'hits' => 4, >> >> 'atbats' => 5, >> >> 'bb' => 0, >> >> 'rbis' => 2, >> >> 'so' => 1 >> >> }, >> >> 'BryceJones(2021)' => { >> >> 'hits' => 2, >> >> 'runs' => 2, >> >> 'atbats' => 4, >> >> 'bb' => 1, >> >> 'rbis' => 4, >> >> 'so' => 1 >> >> }, >> >> }; >> >> >> >> This is how I iterate it in perl. >> >> >> >> foreach my $name (sort keys %season) { >> >> printf "%-27.27s", "$name: "; >> >> foreach my $stat (sort keys %{ $season{$name} }) { >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> >> ## cal. avg >> >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; >> >> } >> >> >> >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> >> } >> >> >> >> I then pass it back to my dancer app as a ref. with return \%season; >> >> and then to template toolkit with: >> >> >> >> template 'softball.tt' => { >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> 'Season' => $season, >> >> >> >> >> >> }, {}; >> >> >> >> But I am lost trying to get it to display with template toolkit. >> >> Here's what I've tried so far. >> >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> >> >> Season.val.hits <% Season.value.hits %> >> >>
>> >> <% FOREACH Season = Season %> >> >> >> >> >> >> >> >> >> >> <% END %> >> >> >> >> Thanks for any help. >> >> _______________________________________________ >> >> dancer-users mailing list >> >> dancer-users at lists.preshweb.co.uk >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> > >> > From gatorreina at gmail.com Sun Aug 23 12:21:56 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sun, 23 Aug 2020 11:21:56 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: I am beginning to suspect my html code as well. Will try to simplify and report back. Thanks, again 2020-08-23 9:57 GMT-05:00, Gabor Szabo : > Have you checked the content when you "view source" in the browser? > I had cases when my code did not show up because I had some HTML issues. > I wasted so much time till I figured out the content is there just hidden. > > My example is stand-alone using Template::Toolkit, > when using Dancer you don't need that, you only need to enable it in the > config file > and you pass your data to the "template" function. > > The TT part is almost identical though I think in Dancer we use <% for tags > and not > the default [% as in my example. > > Gabor > > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina wrote: > >> Hi Gabor, >> >> Thank you very much for your help. I appreciate your answer and all >> the wonderful tutorials at perlmaven, but so far I am unable to get >> this answer to work for me. My my hash %season seems to look the same >> as your %payload but when I try your solution only the name of the >> player is displayed. I do not use 'use Template'; in my backend code >> and am not really sure what the exact role of create.pl, is it for >> teaching purposes or is there a step within it that I must apply to >> get my %season to look like your %payload before I return it to my >> Dancer app? I will continue to experiment with your solution and try >> to find a place where I can post exactly what I am getting as a >> result. >> >> Thanks again, >> >> Richard >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : >> > I am not sure if this is what you meant, but using your data I wrote >> > two >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash >> > >> > Gabor >> > >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina >> > wrote: >> > >> >> I have the following perl multidimensional hash that is passed from >> >> Dancer to Template Toolkit as a hash reference. I am having trouble >> >> figuring out how to display it in Template Toolkit. >> >> >> >> $VAR1 = { >> >> 'TylerMontgomery(2022)' => { >> >> 'so' => 1, >> >> 'bb' => 1, >> >> 'rbis' => 0, >> >> 'atbats' => 7, >> >> 'runs' => 2, >> >> 'hits' => 2 >> >> }, >> >> 'ChaseLangan(2022)' => { >> >> 'runs' => 4, >> >> 'hits' => 4, >> >> 'atbats' => 5, >> >> 'bb' => 0, >> >> 'rbis' => 2, >> >> 'so' => 1 >> >> }, >> >> 'BryceJones(2021)' => { >> >> 'hits' => 2, >> >> 'runs' => 2, >> >> 'atbats' => 4, >> >> 'bb' => 1, >> >> 'rbis' => 4, >> >> 'so' => 1 >> >> }, >> >> }; >> >> >> >> This is how I iterate it in perl. >> >> >> >> foreach my $name (sort keys %season) { >> >> printf "%-27.27s", "$name: "; >> >> foreach my $stat (sort keys %{ $season{$name} }) { >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> >> ## cal. avg >> >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; >> >> } >> >> >> >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> >> } >> >> >> >> I then pass it back to my dancer app as a ref. with return \%season; >> >> and then to template toolkit with: >> >> >> >> template 'softball.tt' => { >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> 'Season' => $season, >> >> >> >> >> >> }, {}; >> >> >> >> But I am lost trying to get it to display with template toolkit. >> >> Here's what I've tried so far. >> >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> >> >> Season.val.hits <% Season.value.hits %> >> >>
>> >> <% FOREACH Season = Season %> >> >> >> >> >> >> >> >> >> >> <% END %> >> >> >> >> Thanks for any help. >> >> _______________________________________________ >> >> dancer-users mailing list >> >> dancer-users at lists.preshweb.co.uk >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> > >> > From gatorreina at gmail.com Sun Aug 23 13:45:18 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sun, 23 Aug 2020 12:45:18 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: Ok, maybe I've overlooked something but here is what I get with very simple call to a route and using very simple html. http://paste.scsys.co.uk/592477 2020-08-23 9:57 GMT-05:00, Gabor Szabo : > Have you checked the content when you "view source" in the browser? > I had cases when my code did not show up because I had some HTML issues. > I wasted so much time till I figured out the content is there just hidden. > > My example is stand-alone using Template::Toolkit, > when using Dancer you don't need that, you only need to enable it in the > config file > and you pass your data to the "template" function. > > The TT part is almost identical though I think in Dancer we use <% for tags > and not > the default [% as in my example. > > Gabor > > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina wrote: > >> Hi Gabor, >> >> Thank you very much for your help. I appreciate your answer and all >> the wonderful tutorials at perlmaven, but so far I am unable to get >> this answer to work for me. My my hash %season seems to look the same >> as your %payload but when I try your solution only the name of the >> player is displayed. I do not use 'use Template'; in my backend code >> and am not really sure what the exact role of create.pl, is it for >> teaching purposes or is there a step within it that I must apply to >> get my %season to look like your %payload before I return it to my >> Dancer app? I will continue to experiment with your solution and try >> to find a place where I can post exactly what I am getting as a >> result. >> >> Thanks again, >> >> Richard >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : >> > I am not sure if this is what you meant, but using your data I wrote >> > two >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash >> > >> > Gabor >> > >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina >> > wrote: >> > >> >> I have the following perl multidimensional hash that is passed from >> >> Dancer to Template Toolkit as a hash reference. I am having trouble >> >> figuring out how to display it in Template Toolkit. >> >> >> >> $VAR1 = { >> >> 'TylerMontgomery(2022)' => { >> >> 'so' => 1, >> >> 'bb' => 1, >> >> 'rbis' => 0, >> >> 'atbats' => 7, >> >> 'runs' => 2, >> >> 'hits' => 2 >> >> }, >> >> 'ChaseLangan(2022)' => { >> >> 'runs' => 4, >> >> 'hits' => 4, >> >> 'atbats' => 5, >> >> 'bb' => 0, >> >> 'rbis' => 2, >> >> 'so' => 1 >> >> }, >> >> 'BryceJones(2021)' => { >> >> 'hits' => 2, >> >> 'runs' => 2, >> >> 'atbats' => 4, >> >> 'bb' => 1, >> >> 'rbis' => 4, >> >> 'so' => 1 >> >> }, >> >> }; >> >> >> >> This is how I iterate it in perl. >> >> >> >> foreach my $name (sort keys %season) { >> >> printf "%-27.27s", "$name: "; >> >> foreach my $stat (sort keys %{ $season{$name} }) { >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> >> ## cal. avg >> >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; >> >> } >> >> >> >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> >> } >> >> >> >> I then pass it back to my dancer app as a ref. with return \%season; >> >> and then to template toolkit with: >> >> >> >> template 'softball.tt' => { >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> 'Season' => $season, >> >> >> >> >> >> }, {}; >> >> >> >> But I am lost trying to get it to display with template toolkit. >> >> Here's what I've tried so far. >> >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> >> >> Season.val.hits <% Season.value.hits %> >> >>
>> >> <% FOREACH Season = Season %> >> >> >> >> >> >> >> >> >> >> <% END %> >> >> >> >> Thanks for any help. >> >> _______________________________________________ >> >> dancer-users mailing list >> >> dancer-users at lists.preshweb.co.uk >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> > >> > From gatorreina at gmail.com Sun Aug 23 13:45:18 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sun, 23 Aug 2020 12:45:18 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: Ok, maybe I've overlooked something but here is what I get with very simple call to a route and using very simple html. http://paste.scsys.co.uk/592477 2020-08-23 9:57 GMT-05:00, Gabor Szabo : > Have you checked the content when you "view source" in the browser? > I had cases when my code did not show up because I had some HTML issues. > I wasted so much time till I figured out the content is there just hidden. > > My example is stand-alone using Template::Toolkit, > when using Dancer you don't need that, you only need to enable it in the > config file > and you pass your data to the "template" function. > > The TT part is almost identical though I think in Dancer we use <% for tags > and not > the default [% as in my example. > > Gabor > > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina wrote: > >> Hi Gabor, >> >> Thank you very much for your help. I appreciate your answer and all >> the wonderful tutorials at perlmaven, but so far I am unable to get >> this answer to work for me. My my hash %season seems to look the same >> as your %payload but when I try your solution only the name of the >> player is displayed. I do not use 'use Template'; in my backend code >> and am not really sure what the exact role of create.pl, is it for >> teaching purposes or is there a step within it that I must apply to >> get my %season to look like your %payload before I return it to my >> Dancer app? I will continue to experiment with your solution and try >> to find a place where I can post exactly what I am getting as a >> result. >> >> Thanks again, >> >> Richard >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : >> > I am not sure if this is what you meant, but using your data I wrote >> > two >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash >> > >> > Gabor >> > >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina >> > wrote: >> > >> >> I have the following perl multidimensional hash that is passed from >> >> Dancer to Template Toolkit as a hash reference. I am having trouble >> >> figuring out how to display it in Template Toolkit. >> >> >> >> $VAR1 = { >> >> 'TylerMontgomery(2022)' => { >> >> 'so' => 1, >> >> 'bb' => 1, >> >> 'rbis' => 0, >> >> 'atbats' => 7, >> >> 'runs' => 2, >> >> 'hits' => 2 >> >> }, >> >> 'ChaseLangan(2022)' => { >> >> 'runs' => 4, >> >> 'hits' => 4, >> >> 'atbats' => 5, >> >> 'bb' => 0, >> >> 'rbis' => 2, >> >> 'so' => 1 >> >> }, >> >> 'BryceJones(2021)' => { >> >> 'hits' => 2, >> >> 'runs' => 2, >> >> 'atbats' => 4, >> >> 'bb' => 1, >> >> 'rbis' => 4, >> >> 'so' => 1 >> >> }, >> >> }; >> >> >> >> This is how I iterate it in perl. >> >> >> >> foreach my $name (sort keys %season) { >> >> printf "%-27.27s", "$name: "; >> >> foreach my $stat (sort keys %{ $season{$name} }) { >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> >> ## cal. avg >> >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; >> >> } >> >> >> >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> >> } >> >> >> >> I then pass it back to my dancer app as a ref. with return \%season; >> >> and then to template toolkit with: >> >> >> >> template 'softball.tt' => { >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> 'Season' => $season, >> >> >> >> >> >> }, {}; >> >> >> >> But I am lost trying to get it to display with template toolkit. >> >> Here's what I've tried so far. >> >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> >> >> Season.val.hits <% Season.value.hits %> >> >>
>> >> <% FOREACH Season = Season %> >> >> >> >> >> >> >> >> >> >> <% END %> >> >> >> >> Thanks for any help. >> >> _______________________________________________ >> >> dancer-users mailing list >> >> dancer-users at lists.preshweb.co.uk >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> > >> > From gabor at szabgab.com Sun Aug 23 13:53:55 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Sun, 23 Aug 2020 20:53:55 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: I think you should be passing references: 'payload' => \%season, See the backslash. Gabor On Sun, Aug 23, 2020 at 8:45 PM Richard Reina wrote: > Ok, maybe I've overlooked something but here is what I get with very > simple call to a route and using very simple html. > > http://paste.scsys.co.uk/592477 > > 2020-08-23 9:57 GMT-05:00, Gabor Szabo : > > Have you checked the content when you "view source" in the browser? > > I had cases when my code did not show up because I had some HTML issues. > > I wasted so much time till I figured out the content is there just > hidden. > > > > My example is stand-alone using Template::Toolkit, > > when using Dancer you don't need that, you only need to enable it in the > > config file > > and you pass your data to the "template" function. > > > > The TT part is almost identical though I think in Dancer we use <% for > tags > > and not > > the default [% as in my example. > > > > Gabor > > > > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina > wrote: > > > >> Hi Gabor, > >> > >> Thank you very much for your help. I appreciate your answer and all > >> the wonderful tutorials at perlmaven, but so far I am unable to get > >> this answer to work for me. My my hash %season seems to look the same > >> as your %payload but when I try your solution only the name of the > >> player is displayed. I do not use 'use Template'; in my backend code > >> and am not really sure what the exact role of create.pl, is it for > >> teaching purposes or is there a step within it that I must apply to > >> get my %season to look like your %payload before I return it to my > >> Dancer app? I will continue to experiment with your solution and try > >> to find a place where I can post exactly what I am getting as a > >> result. > >> > >> Thanks again, > >> > >> Richard > >> > >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : > >> > I am not sure if this is what you meant, but using your data I wrote > >> > two > >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash > >> > > >> > Gabor > >> > > >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina > >> > wrote: > >> > > >> >> I have the following perl multidimensional hash that is passed from > >> >> Dancer to Template Toolkit as a hash reference. I am having trouble > >> >> figuring out how to display it in Template Toolkit. > >> >> > >> >> $VAR1 = { > >> >> 'TylerMontgomery(2022)' => { > >> >> 'so' => 1, > >> >> 'bb' => 1, > >> >> 'rbis' => 0, > >> >> 'atbats' => 7, > >> >> 'runs' => 2, > >> >> 'hits' => 2 > >> >> }, > >> >> 'ChaseLangan(2022)' => { > >> >> 'runs' => 4, > >> >> 'hits' => 4, > >> >> 'atbats' => 5, > >> >> 'bb' => 0, > >> >> 'rbis' => 2, > >> >> 'so' => 1 > >> >> }, > >> >> 'BryceJones(2021)' => { > >> >> 'hits' => 2, > >> >> 'runs' => 2, > >> >> 'atbats' => 4, > >> >> 'bb' => 1, > >> >> 'rbis' => 4, > >> >> 'so' => 1 > >> >> }, > >> >> }; > >> >> > >> >> This is how I iterate it in perl. > >> >> > >> >> foreach my $name (sort keys %season) { > >> >> printf "%-27.27s", "$name: "; > >> >> foreach my $stat (sort keys %{ $season{$name} }) { > >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; > >> >> ## cal. avg > >> >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; > >> >> } > >> >> > >> >> > >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; > >> >> } > >> >> > >> >> I then pass it back to my dancer app as a ref. with return \%season; > >> >> and then to template toolkit with: > >> >> > >> >> template 'softball.tt' => { > >> >> > >> >> 'title' => 'Get Softball Season Stats', > >> >> 'Season' => $season, > >> >> > >> >> > >> >> }, {}; > >> >> > >> >> But I am lost trying to get it to display with template toolkit. > >> >> Here's what I've tried so far. > >> >> > >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> >> >> Season.val.hits <% Season.value.hits %> >> >>
> >> >> <% FOREACH Season = Season %> > >> >> > >> >> > >> >> > >> >> > >> >> <% END %> > >> >> > >> >> Thanks for any help. > >> >> _______________________________________________ > >> >> dancer-users mailing list > >> >> dancer-users at lists.preshweb.co.uk > >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users > >> >> > >> > > >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Sun Aug 23 13:53:55 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Sun, 23 Aug 2020 20:53:55 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: I think you should be passing references: 'payload' => \%season, See the backslash. Gabor On Sun, Aug 23, 2020 at 8:45 PM Richard Reina wrote: > Ok, maybe I've overlooked something but here is what I get with very > simple call to a route and using very simple html. > > http://paste.scsys.co.uk/592477 > > 2020-08-23 9:57 GMT-05:00, Gabor Szabo : > > Have you checked the content when you "view source" in the browser? > > I had cases when my code did not show up because I had some HTML issues. > > I wasted so much time till I figured out the content is there just > hidden. > > > > My example is stand-alone using Template::Toolkit, > > when using Dancer you don't need that, you only need to enable it in the > > config file > > and you pass your data to the "template" function. > > > > The TT part is almost identical though I think in Dancer we use <% for > tags > > and not > > the default [% as in my example. > > > > Gabor > > > > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina > wrote: > > > >> Hi Gabor, > >> > >> Thank you very much for your help. I appreciate your answer and all > >> the wonderful tutorials at perlmaven, but so far I am unable to get > >> this answer to work for me. My my hash %season seems to look the same > >> as your %payload but when I try your solution only the name of the > >> player is displayed. I do not use 'use Template'; in my backend code > >> and am not really sure what the exact role of create.pl, is it for > >> teaching purposes or is there a step within it that I must apply to > >> get my %season to look like your %payload before I return it to my > >> Dancer app? I will continue to experiment with your solution and try > >> to find a place where I can post exactly what I am getting as a > >> result. > >> > >> Thanks again, > >> > >> Richard > >> > >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : > >> > I am not sure if this is what you meant, but using your data I wrote > >> > two > >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash > >> > > >> > Gabor > >> > > >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina > >> > wrote: > >> > > >> >> I have the following perl multidimensional hash that is passed from > >> >> Dancer to Template Toolkit as a hash reference. I am having trouble > >> >> figuring out how to display it in Template Toolkit. > >> >> > >> >> $VAR1 = { > >> >> 'TylerMontgomery(2022)' => { > >> >> 'so' => 1, > >> >> 'bb' => 1, > >> >> 'rbis' => 0, > >> >> 'atbats' => 7, > >> >> 'runs' => 2, > >> >> 'hits' => 2 > >> >> }, > >> >> 'ChaseLangan(2022)' => { > >> >> 'runs' => 4, > >> >> 'hits' => 4, > >> >> 'atbats' => 5, > >> >> 'bb' => 0, > >> >> 'rbis' => 2, > >> >> 'so' => 1 > >> >> }, > >> >> 'BryceJones(2021)' => { > >> >> 'hits' => 2, > >> >> 'runs' => 2, > >> >> 'atbats' => 4, > >> >> 'bb' => 1, > >> >> 'rbis' => 4, > >> >> 'so' => 1 > >> >> }, > >> >> }; > >> >> > >> >> This is how I iterate it in perl. > >> >> > >> >> foreach my $name (sort keys %season) { > >> >> printf "%-27.27s", "$name: "; > >> >> foreach my $stat (sort keys %{ $season{$name} }) { > >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; > >> >> ## cal. avg > >> >> $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats}; > >> >> } > >> >> > >> >> > >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; > >> >> } > >> >> > >> >> I then pass it back to my dancer app as a ref. with return \%season; > >> >> and then to template toolkit with: > >> >> > >> >> template 'softball.tt' => { > >> >> > >> >> 'title' => 'Get Softball Season Stats', > >> >> 'Season' => $season, > >> >> > >> >> > >> >> }, {}; > >> >> > >> >> But I am lost trying to get it to display with template toolkit. > >> >> Here's what I've tried so far. > >> >> > >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> > >> >> Season.val.hits <% Season.value.hits %> > >> >>
> >> >> <% FOREACH Season = Season %> > >> >> > >> >> > >> >> > >> >> > >> >> <% END %> > >> >> > >> >> Thanks for any help. > >> >> _______________________________________________ > >> >> dancer-users mailing list > >> >> dancer-users at lists.preshweb.co.uk > >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users > >> >> > >> > > >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gatorreina at gmail.com Sun Aug 23 14:38:31 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sun, 23 Aug 2020 13:38:31 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: template 'results.tt' => { 'title' => 'Get Softball Season Stats', 'payload' => \%season, }, {}; Results in this: Trying with payload ------------- : Name atbats so bb rbis hits runs 2020-08-23 12:53 GMT-05:00, Gabor Szabo : > I think you should be passing references: > > 'payload' => \%season, > > See the backslash. > > Gabor > > > > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina wrote: > >> Ok, maybe I've overlooked something but here is what I get with very >> simple call to a route and using very simple html. >> >> http://paste.scsys.co.uk/592477 >> >> 2020-08-23 9:57 GMT-05:00, Gabor Szabo : >> > Have you checked the content when you "view source" in the browser? >> > I had cases when my code did not show up because I had some HTML >> > issues. >> > I wasted so much time till I figured out the content is there just >> hidden. >> > >> > My example is stand-alone using Template::Toolkit, >> > when using Dancer you don't need that, you only need to enable it in >> > the >> > config file >> > and you pass your data to the "template" function. >> > >> > The TT part is almost identical though I think in Dancer we use <% for >> tags >> > and not >> > the default [% as in my example. >> > >> > Gabor >> > >> > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina >> wrote: >> > >> >> Hi Gabor, >> >> >> >> Thank you very much for your help. I appreciate your answer and all >> >> the wonderful tutorials at perlmaven, but so far I am unable to get >> >> this answer to work for me. My my hash %season seems to look the same >> >> as your %payload but when I try your solution only the name of the >> >> player is displayed. I do not use 'use Template'; in my backend code >> >> and am not really sure what the exact role of create.pl, is it for >> >> teaching purposes or is there a step within it that I must apply to >> >> get my %season to look like your %payload before I return it to my >> >> Dancer app? I will continue to experiment with your solution and try >> >> to find a place where I can post exactly what I am getting as a >> >> result. >> >> >> >> Thanks again, >> >> >> >> Richard >> >> >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : >> >> > I am not sure if this is what you meant, but using your data I wrote >> >> > two >> >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash >> >> > >> >> > Gabor >> >> > >> >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina >> >> > >> >> > wrote: >> >> > >> >> >> I have the following perl multidimensional hash that is passed from >> >> >> Dancer to Template Toolkit as a hash reference. I am having trouble >> >> >> figuring out how to display it in Template Toolkit. >> >> >> >> >> >> $VAR1 = { >> >> >> 'TylerMontgomery(2022)' => { >> >> >> 'so' => 1, >> >> >> 'bb' => 1, >> >> >> 'rbis' => 0, >> >> >> 'atbats' => 7, >> >> >> 'runs' => 2, >> >> >> 'hits' => 2 >> >> >> }, >> >> >> 'ChaseLangan(2022)' => { >> >> >> 'runs' => 4, >> >> >> 'hits' => 4, >> >> >> 'atbats' => 5, >> >> >> 'bb' => 0, >> >> >> 'rbis' => 2, >> >> >> 'so' => 1 >> >> >> }, >> >> >> 'BryceJones(2021)' => { >> >> >> 'hits' => 2, >> >> >> 'runs' => 2, >> >> >> 'atbats' => 4, >> >> >> 'bb' => 1, >> >> >> 'rbis' => 4, >> >> >> 'so' => 1 >> >> >> }, >> >> >> }; >> >> >> >> >> >> This is how I iterate it in perl. >> >> >> >> >> >> foreach my $name (sort keys %season) { >> >> >> printf "%-27.27s", "$name: "; >> >> >> foreach my $stat (sort keys %{ $season{$name} }) { >> >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> >> >> ## cal. avg >> >> >> $season{$name}{AVG} = $season{$name}{hits} / >> >> >> $season{$name}{atbats}; >> >> >> } >> >> >> >> >> >> >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> >> >> } >> >> >> >> >> >> I then pass it back to my dancer app as a ref. with return >> >> >> \%season; >> >> >> and then to template toolkit with: >> >> >> >> >> >> template 'softball.tt' => { >> >> >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> >> 'Season' => $season, >> >> >> >> >> >> >> >> >> }, {}; >> >> >> >> >> >> But I am lost trying to get it to display with template toolkit. >> >> >> Here's what I've tried so far. >> >> >> >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> > >> >> Season.val.hits <% Season.value.hits %> > >> >>
>> >> >> <% FOREACH Season = Season %> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> <% END %> >> >> >> >> >> >> Thanks for any help. >> >> >> _______________________________________________ >> >> >> dancer-users mailing list >> >> >> dancer-users at lists.preshweb.co.uk >> >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> >> >> > >> >> >> > >> > From gatorreina at gmail.com Sun Aug 23 14:38:31 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sun, 23 Aug 2020 13:38:31 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: template 'results.tt' => { 'title' => 'Get Softball Season Stats', 'payload' => \%season, }, {}; Results in this: Trying with payload ------------- : Name atbats so bb rbis hits runs 2020-08-23 12:53 GMT-05:00, Gabor Szabo : > I think you should be passing references: > > 'payload' => \%season, > > See the backslash. > > Gabor > > > > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina wrote: > >> Ok, maybe I've overlooked something but here is what I get with very >> simple call to a route and using very simple html. >> >> http://paste.scsys.co.uk/592477 >> >> 2020-08-23 9:57 GMT-05:00, Gabor Szabo : >> > Have you checked the content when you "view source" in the browser? >> > I had cases when my code did not show up because I had some HTML >> > issues. >> > I wasted so much time till I figured out the content is there just >> hidden. >> > >> > My example is stand-alone using Template::Toolkit, >> > when using Dancer you don't need that, you only need to enable it in >> > the >> > config file >> > and you pass your data to the "template" function. >> > >> > The TT part is almost identical though I think in Dancer we use <% for >> tags >> > and not >> > the default [% as in my example. >> > >> > Gabor >> > >> > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina >> wrote: >> > >> >> Hi Gabor, >> >> >> >> Thank you very much for your help. I appreciate your answer and all >> >> the wonderful tutorials at perlmaven, but so far I am unable to get >> >> this answer to work for me. My my hash %season seems to look the same >> >> as your %payload but when I try your solution only the name of the >> >> player is displayed. I do not use 'use Template'; in my backend code >> >> and am not really sure what the exact role of create.pl, is it for >> >> teaching purposes or is there a step within it that I must apply to >> >> get my %season to look like your %payload before I return it to my >> >> Dancer app? I will continue to experiment with your solution and try >> >> to find a place where I can post exactly what I am getting as a >> >> result. >> >> >> >> Thanks again, >> >> >> >> Richard >> >> >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : >> >> > I am not sure if this is what you meant, but using your data I wrote >> >> > two >> >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash >> >> > >> >> > Gabor >> >> > >> >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina >> >> > >> >> > wrote: >> >> > >> >> >> I have the following perl multidimensional hash that is passed from >> >> >> Dancer to Template Toolkit as a hash reference. I am having trouble >> >> >> figuring out how to display it in Template Toolkit. >> >> >> >> >> >> $VAR1 = { >> >> >> 'TylerMontgomery(2022)' => { >> >> >> 'so' => 1, >> >> >> 'bb' => 1, >> >> >> 'rbis' => 0, >> >> >> 'atbats' => 7, >> >> >> 'runs' => 2, >> >> >> 'hits' => 2 >> >> >> }, >> >> >> 'ChaseLangan(2022)' => { >> >> >> 'runs' => 4, >> >> >> 'hits' => 4, >> >> >> 'atbats' => 5, >> >> >> 'bb' => 0, >> >> >> 'rbis' => 2, >> >> >> 'so' => 1 >> >> >> }, >> >> >> 'BryceJones(2021)' => { >> >> >> 'hits' => 2, >> >> >> 'runs' => 2, >> >> >> 'atbats' => 4, >> >> >> 'bb' => 1, >> >> >> 'rbis' => 4, >> >> >> 'so' => 1 >> >> >> }, >> >> >> }; >> >> >> >> >> >> This is how I iterate it in perl. >> >> >> >> >> >> foreach my $name (sort keys %season) { >> >> >> printf "%-27.27s", "$name: "; >> >> >> foreach my $stat (sort keys %{ $season{$name} }) { >> >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> >> >> ## cal. avg >> >> >> $season{$name}{AVG} = $season{$name}{hits} / >> >> >> $season{$name}{atbats}; >> >> >> } >> >> >> >> >> >> >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> >> >> } >> >> >> >> >> >> I then pass it back to my dancer app as a ref. with return >> >> >> \%season; >> >> >> and then to template toolkit with: >> >> >> >> >> >> template 'softball.tt' => { >> >> >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> >> 'Season' => $season, >> >> >> >> >> >> >> >> >> }, {}; >> >> >> >> >> >> But I am lost trying to get it to display with template toolkit. >> >> >> Here's what I've tried so far. >> >> >> >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> >> >> >> Season.val.hits <% Season.value.hits %> >> >> >>
>> >> >> <% FOREACH Season = Season %> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> <% END %> >> >> >> >> >> >> Thanks for any help. >> >> >> _______________________________________________ >> >> >> dancer-users mailing list >> >> >> dancer-users at lists.preshweb.co.uk >> >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> >> >> > >> >> >> > >> > From gabor at szabgab.com Sun Aug 23 15:22:45 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Sun, 23 Aug 2020 22:22:45 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: OK, so I don't understand why do you pass the same %payload 3 times, but you need to pass references in all 3 cases. template 'results.tt' => { 'title' => 'Get Softball Season Stats', 'games' => \%season, 'season' => \%season, 'payload' => \%season, 'F_NAME' => 'Geraldo', }, {}; On Sun, Aug 23, 2020 at 9:38 PM Richard Reina wrote: > template 'results.tt' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => \%season, > > }, {}; > > Results in this: > > Trying with payload > ------------- : > > Name atbats so bb rbis hits runs > > > > 2020-08-23 12:53 GMT-05:00, Gabor Szabo : > > I think you should be passing references: > > > > 'payload' => \%season, > > > > See the backslash. > > > > Gabor > > > > > > > > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina > wrote: > > > >> Ok, maybe I've overlooked something but here is what I get with very > >> simple call to a route and using very simple html. > >> > >> http://paste.scsys.co.uk/592477 > >> > >> 2020-08-23 9:57 GMT-05:00, Gabor Szabo : > >> > Have you checked the content when you "view source" in the browser? > >> > I had cases when my code did not show up because I had some HTML > >> > issues. > >> > I wasted so much time till I figured out the content is there just > >> hidden. > >> > > >> > My example is stand-alone using Template::Toolkit, > >> > when using Dancer you don't need that, you only need to enable it in > >> > the > >> > config file > >> > and you pass your data to the "template" function. > >> > > >> > The TT part is almost identical though I think in Dancer we use <% for > >> tags > >> > and not > >> > the default [% as in my example. > >> > > >> > Gabor > >> > > >> > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina > >> wrote: > >> > > >> >> Hi Gabor, > >> >> > >> >> Thank you very much for your help. I appreciate your answer and all > >> >> the wonderful tutorials at perlmaven, but so far I am unable to get > >> >> this answer to work for me. My my hash %season seems to look the same > >> >> as your %payload but when I try your solution only the name of the > >> >> player is displayed. I do not use 'use Template'; in my backend code > >> >> and am not really sure what the exact role of create.pl, is it for > >> >> teaching purposes or is there a step within it that I must apply to > >> >> get my %season to look like your %payload before I return it to my > >> >> Dancer app? I will continue to experiment with your solution and try > >> >> to find a place where I can post exactly what I am getting as a > >> >> result. > >> >> > >> >> Thanks again, > >> >> > >> >> Richard > >> >> > >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : > >> >> > I am not sure if this is what you meant, but using your data I > wrote > >> >> > two > >> >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash > >> >> > > >> >> > Gabor > >> >> > > >> >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina > >> >> > > >> >> > wrote: > >> >> > > >> >> >> I have the following perl multidimensional hash that is passed > from > >> >> >> Dancer to Template Toolkit as a hash reference. I am having > trouble > >> >> >> figuring out how to display it in Template Toolkit. > >> >> >> > >> >> >> $VAR1 = { > >> >> >> 'TylerMontgomery(2022)' => { > >> >> >> 'so' => 1, > >> >> >> 'bb' => 1, > >> >> >> 'rbis' => 0, > >> >> >> 'atbats' => 7, > >> >> >> 'runs' => 2, > >> >> >> 'hits' => 2 > >> >> >> }, > >> >> >> 'ChaseLangan(2022)' => { > >> >> >> 'runs' => 4, > >> >> >> 'hits' => 4, > >> >> >> 'atbats' => 5, > >> >> >> 'bb' => 0, > >> >> >> 'rbis' => 2, > >> >> >> 'so' => 1 > >> >> >> }, > >> >> >> 'BryceJones(2021)' => { > >> >> >> 'hits' => 2, > >> >> >> 'runs' => 2, > >> >> >> 'atbats' => 4, > >> >> >> 'bb' => 1, > >> >> >> 'rbis' => 4, > >> >> >> 'so' => 1 > >> >> >> }, > >> >> >> }; > >> >> >> > >> >> >> This is how I iterate it in perl. > >> >> >> > >> >> >> foreach my $name (sort keys %season) { > >> >> >> printf "%-27.27s", "$name: "; > >> >> >> foreach my $stat (sort keys %{ $season{$name} }) { > >> >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; > >> >> >> ## cal. avg > >> >> >> $season{$name}{AVG} = $season{$name}{hits} / > >> >> >> $season{$name}{atbats}; > >> >> >> } > >> >> >> > >> >> >> > >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; > >> >> >> } > >> >> >> > >> >> >> I then pass it back to my dancer app as a ref. with return > >> >> >> \%season; > >> >> >> and then to template toolkit with: > >> >> >> > >> >> >> template 'softball.tt' => { > >> >> >> > >> >> >> 'title' => 'Get Softball Season Stats', > >> >> >> 'Season' => $season, > >> >> >> > >> >> >> > >> >> >> }, {}; > >> >> >> > >> >> >> But I am lost trying to get it to display with template toolkit. > >> >> >> Here's what I've tried so far. > >> >> >> > >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats %> >> >> >> Season.val.hits <% Season.value.hits %> >> >> >>
> >> >> >> <% FOREACH Season = Season %> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> <% END %> > >> >> >> > >> >> >> Thanks for any help. > >> >> >> _______________________________________________ > >> >> >> dancer-users mailing list > >> >> >> dancer-users at lists.preshweb.co.uk > >> >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users > >> >> >> > >> >> > > >> >> > >> > > >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Sun Aug 23 15:22:45 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Sun, 23 Aug 2020 22:22:45 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: OK, so I don't understand why do you pass the same %payload 3 times, but you need to pass references in all 3 cases. template 'results.tt' => { 'title' => 'Get Softball Season Stats', 'games' => \%season, 'season' => \%season, 'payload' => \%season, 'F_NAME' => 'Geraldo', }, {}; On Sun, Aug 23, 2020 at 9:38 PM Richard Reina wrote: > template 'results.tt' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => \%season, > > }, {}; > > Results in this: > > Trying with payload > ------------- : > > Name atbats so bb rbis hits runs > > > > 2020-08-23 12:53 GMT-05:00, Gabor Szabo : > > I think you should be passing references: > > > > 'payload' => \%season, > > > > See the backslash. > > > > Gabor > > > > > > > > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina > wrote: > > > >> Ok, maybe I've overlooked something but here is what I get with very > >> simple call to a route and using very simple html. > >> > >> http://paste.scsys.co.uk/592477 > >> > >> 2020-08-23 9:57 GMT-05:00, Gabor Szabo : > >> > Have you checked the content when you "view source" in the browser? > >> > I had cases when my code did not show up because I had some HTML > >> > issues. > >> > I wasted so much time till I figured out the content is there just > >> hidden. > >> > > >> > My example is stand-alone using Template::Toolkit, > >> > when using Dancer you don't need that, you only need to enable it in > >> > the > >> > config file > >> > and you pass your data to the "template" function. > >> > > >> > The TT part is almost identical though I think in Dancer we use <% for > >> tags > >> > and not > >> > the default [% as in my example. > >> > > >> > Gabor > >> > > >> > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina > >> wrote: > >> > > >> >> Hi Gabor, > >> >> > >> >> Thank you very much for your help. I appreciate your answer and all > >> >> the wonderful tutorials at perlmaven, but so far I am unable to get > >> >> this answer to work for me. My my hash %season seems to look the same > >> >> as your %payload but when I try your solution only the name of the > >> >> player is displayed. I do not use 'use Template'; in my backend code > >> >> and am not really sure what the exact role of create.pl, is it for > >> >> teaching purposes or is there a step within it that I must apply to > >> >> get my %season to look like your %payload before I return it to my > >> >> Dancer app? I will continue to experiment with your solution and try > >> >> to find a place where I can post exactly what I am getting as a > >> >> result. > >> >> > >> >> Thanks again, > >> >> > >> >> Richard > >> >> > >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : > >> >> > I am not sure if this is what you meant, but using your data I > wrote > >> >> > two > >> >> > examples here: https://perlmaven.com/template-toolkit-hash-of-hash > >> >> > > >> >> > Gabor > >> >> > > >> >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina > >> >> > > >> >> > wrote: > >> >> > > >> >> >> I have the following perl multidimensional hash that is passed > from > >> >> >> Dancer to Template Toolkit as a hash reference. I am having > trouble > >> >> >> figuring out how to display it in Template Toolkit. > >> >> >> > >> >> >> $VAR1 = { > >> >> >> 'TylerMontgomery(2022)' => { > >> >> >> 'so' => 1, > >> >> >> 'bb' => 1, > >> >> >> 'rbis' => 0, > >> >> >> 'atbats' => 7, > >> >> >> 'runs' => 2, > >> >> >> 'hits' => 2 > >> >> >> }, > >> >> >> 'ChaseLangan(2022)' => { > >> >> >> 'runs' => 4, > >> >> >> 'hits' => 4, > >> >> >> 'atbats' => 5, > >> >> >> 'bb' => 0, > >> >> >> 'rbis' => 2, > >> >> >> 'so' => 1 > >> >> >> }, > >> >> >> 'BryceJones(2021)' => { > >> >> >> 'hits' => 2, > >> >> >> 'runs' => 2, > >> >> >> 'atbats' => 4, > >> >> >> 'bb' => 1, > >> >> >> 'rbis' => 4, > >> >> >> 'so' => 1 > >> >> >> }, > >> >> >> }; > >> >> >> > >> >> >> This is how I iterate it in perl. > >> >> >> > >> >> >> foreach my $name (sort keys %season) { > >> >> >> printf "%-27.27s", "$name: "; > >> >> >> foreach my $stat (sort keys %{ $season{$name} }) { > >> >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; > >> >> >> ## cal. avg > >> >> >> $season{$name}{AVG} = $season{$name}{hits} / > >> >> >> $season{$name}{atbats}; > >> >> >> } > >> >> >> > >> >> >> > >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; > >> >> >> } > >> >> >> > >> >> >> I then pass it back to my dancer app as a ref. with return > >> >> >> \%season; > >> >> >> and then to template toolkit with: > >> >> >> > >> >> >> template 'softball.tt' => { > >> >> >> > >> >> >> 'title' => 'Get Softball Season Stats', > >> >> >> 'Season' => $season, > >> >> >> > >> >> >> > >> >> >> }, {}; > >> >> >> > >> >> >> But I am lost trying to get it to display with template toolkit. > >> >> >> Here's what I've tried so far. > >> >> >> > >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats > %> > >> >> >> Season.val.hits <% Season.value.hits %> > >> >> >>
> >> >> >> <% FOREACH Season = Season %> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> <% END %> > >> >> >> > >> >> >> Thanks for any help. > >> >> >> _______________________________________________ > >> >> >> dancer-users mailing list > >> >> >> dancer-users at lists.preshweb.co.uk > >> >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users > >> >> >> > >> >> > > >> >> > >> > > >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gatorreina at gmail.com Sun Aug 23 15:44:25 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sun, 23 Aug 2020 14:44:25 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: I was merely passing it as with different var name to distinguish from different attempts in my html. Taking out the other case, as I have done, has no effect on the results. This is what is being passed the html in the paste above: template 'results.tt' => { 'title' => 'Get Softball Season Stats', 'payload' => %season, }, {}; And this is the result: Trying with payload TylerMontgomery(2022) ------------- TylerMontgomery(2022) : TylerMontgomery(2022) Name atbats so bb rbis hits runs TylerMontgomery(2022) 2020-08-23 14:22 GMT-05:00, Gabor Szabo : > OK, so I don't understand why do you pass the same %payload 3 times, but > you need to pass references in all 3 cases. > > template 'results.tt' => { > 'title' => 'Get Softball Season Stats', > 'games' => \%season, > 'season' => \%season, > 'payload' => \%season, > 'F_NAME' => 'Geraldo', > > > }, {}; > > On Sun, Aug 23, 2020 at 9:38 PM Richard Reina wrote: > >> template 'results.tt' => { >> >> 'title' => 'Get Softball Season Stats', >> 'payload' => \%season, >> >> }, {}; >> >> Results in this: >> >> Trying with payload >> ------------- : >> >> Name atbats so bb rbis hits runs >> >> >> >> 2020-08-23 12:53 GMT-05:00, Gabor Szabo : >> > I think you should be passing references: >> > >> > 'payload' => \%season, >> > >> > See the backslash. >> > >> > Gabor >> > >> > >> > >> > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina >> wrote: >> > >> >> Ok, maybe I've overlooked something but here is what I get with very >> >> simple call to a route and using very simple html. >> >> >> >> http://paste.scsys.co.uk/592477 >> >> >> >> 2020-08-23 9:57 GMT-05:00, Gabor Szabo : >> >> > Have you checked the content when you "view source" in the browser? >> >> > I had cases when my code did not show up because I had some HTML >> >> > issues. >> >> > I wasted so much time till I figured out the content is there just >> >> hidden. >> >> > >> >> > My example is stand-alone using Template::Toolkit, >> >> > when using Dancer you don't need that, you only need to enable it in >> >> > the >> >> > config file >> >> > and you pass your data to the "template" function. >> >> > >> >> > The TT part is almost identical though I think in Dancer we use <% >> >> > for >> >> tags >> >> > and not >> >> > the default [% as in my example. >> >> > >> >> > Gabor >> >> > >> >> > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina >> >> wrote: >> >> > >> >> >> Hi Gabor, >> >> >> >> >> >> Thank you very much for your help. I appreciate your answer and all >> >> >> the wonderful tutorials at perlmaven, but so far I am unable to get >> >> >> this answer to work for me. My my hash %season seems to look the >> >> >> same >> >> >> as your %payload but when I try your solution only the name of the >> >> >> player is displayed. I do not use 'use Template'; in my backend >> >> >> code >> >> >> and am not really sure what the exact role of create.pl, is it for >> >> >> teaching purposes or is there a step within it that I must apply to >> >> >> get my %season to look like your %payload before I return it to my >> >> >> Dancer app? I will continue to experiment with your solution and >> >> >> try >> >> >> to find a place where I can post exactly what I am getting as a >> >> >> result. >> >> >> >> >> >> Thanks again, >> >> >> >> >> >> Richard >> >> >> >> >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : >> >> >> > I am not sure if this is what you meant, but using your data I >> wrote >> >> >> > two >> >> >> > examples here: >> >> >> > https://perlmaven.com/template-toolkit-hash-of-hash >> >> >> > >> >> >> > Gabor >> >> >> > >> >> >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina >> >> >> > >> >> >> > wrote: >> >> >> > >> >> >> >> I have the following perl multidimensional hash that is passed >> from >> >> >> >> Dancer to Template Toolkit as a hash reference. I am having >> trouble >> >> >> >> figuring out how to display it in Template Toolkit. >> >> >> >> >> >> >> >> $VAR1 = { >> >> >> >> 'TylerMontgomery(2022)' => { >> >> >> >> 'so' => 1, >> >> >> >> 'bb' => 1, >> >> >> >> 'rbis' => 0, >> >> >> >> 'atbats' => 7, >> >> >> >> 'runs' => 2, >> >> >> >> 'hits' => 2 >> >> >> >> }, >> >> >> >> 'ChaseLangan(2022)' => { >> >> >> >> 'runs' => 4, >> >> >> >> 'hits' => 4, >> >> >> >> 'atbats' => 5, >> >> >> >> 'bb' => 0, >> >> >> >> 'rbis' => 2, >> >> >> >> 'so' => 1 >> >> >> >> }, >> >> >> >> 'BryceJones(2021)' => { >> >> >> >> 'hits' => 2, >> >> >> >> 'runs' => 2, >> >> >> >> 'atbats' => 4, >> >> >> >> 'bb' => 1, >> >> >> >> 'rbis' => 4, >> >> >> >> 'so' => 1 >> >> >> >> }, >> >> >> >> }; >> >> >> >> >> >> >> >> This is how I iterate it in perl. >> >> >> >> >> >> >> >> foreach my $name (sort keys %season) { >> >> >> >> printf "%-27.27s", "$name: "; >> >> >> >> foreach my $stat (sort keys %{ $season{$name} }) { >> >> >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> >> >> >> ## cal. avg >> >> >> >> $season{$name}{AVG} = $season{$name}{hits} / >> >> >> >> $season{$name}{atbats}; >> >> >> >> } >> >> >> >> >> >> >> >> >> >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> >> >> >> } >> >> >> >> >> >> >> >> I then pass it back to my dancer app as a ref. with return >> >> >> >> \%season; >> >> >> >> and then to template toolkit with: >> >> >> >> >> >> >> >> template 'softball.tt' => { >> >> >> >> >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> >> >> 'Season' => $season, >> >> >> >> >> >> >> >> >> >> >> >> }, {}; >> >> >> >> >> >> >> >> But I am lost trying to get it to display with template toolkit. >> >> >> >> Here's what I've tried so far. >> >> >> >> >> >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats > %> > >> >> >> Season.val.hits <% Season.value.hits %> > >> >> >>
>> >> >> >> <% FOREACH Season = Season %> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> <% END %> >> >> >> >> >> >> >> >> Thanks for any help. >> >> >> >> _______________________________________________ >> >> >> >> dancer-users mailing list >> >> >> >> dancer-users at lists.preshweb.co.uk >> >> >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> >> >> >> >> > >> >> >> >> >> > >> >> >> > >> > From gatorreina at gmail.com Sun Aug 23 15:44:25 2020 From: gatorreina at gmail.com (Richard Reina) Date: Sun, 23 Aug 2020 14:44:25 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: I was merely passing it as with different var name to distinguish from different attempts in my html. Taking out the other case, as I have done, has no effect on the results. This is what is being passed the html in the paste above: template 'results.tt' => { 'title' => 'Get Softball Season Stats', 'payload' => %season, }, {}; And this is the result: Trying with payload TylerMontgomery(2022) ------------- TylerMontgomery(2022) : TylerMontgomery(2022) Name atbats so bb rbis hits runs TylerMontgomery(2022) 2020-08-23 14:22 GMT-05:00, Gabor Szabo : > OK, so I don't understand why do you pass the same %payload 3 times, but > you need to pass references in all 3 cases. > > template 'results.tt' => { > 'title' => 'Get Softball Season Stats', > 'games' => \%season, > 'season' => \%season, > 'payload' => \%season, > 'F_NAME' => 'Geraldo', > > > }, {}; > > On Sun, Aug 23, 2020 at 9:38 PM Richard Reina wrote: > >> template 'results.tt' => { >> >> 'title' => 'Get Softball Season Stats', >> 'payload' => \%season, >> >> }, {}; >> >> Results in this: >> >> Trying with payload >> ------------- : >> >> Name atbats so bb rbis hits runs >> >> >> >> 2020-08-23 12:53 GMT-05:00, Gabor Szabo : >> > I think you should be passing references: >> > >> > 'payload' => \%season, >> > >> > See the backslash. >> > >> > Gabor >> > >> > >> > >> > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina >> wrote: >> > >> >> Ok, maybe I've overlooked something but here is what I get with very >> >> simple call to a route and using very simple html. >> >> >> >> http://paste.scsys.co.uk/592477 >> >> >> >> 2020-08-23 9:57 GMT-05:00, Gabor Szabo : >> >> > Have you checked the content when you "view source" in the browser? >> >> > I had cases when my code did not show up because I had some HTML >> >> > issues. >> >> > I wasted so much time till I figured out the content is there just >> >> hidden. >> >> > >> >> > My example is stand-alone using Template::Toolkit, >> >> > when using Dancer you don't need that, you only need to enable it in >> >> > the >> >> > config file >> >> > and you pass your data to the "template" function. >> >> > >> >> > The TT part is almost identical though I think in Dancer we use <% >> >> > for >> >> tags >> >> > and not >> >> > the default [% as in my example. >> >> > >> >> > Gabor >> >> > >> >> > On Sun, Aug 23, 2020 at 5:46 PM Richard Reina >> >> wrote: >> >> > >> >> >> Hi Gabor, >> >> >> >> >> >> Thank you very much for your help. I appreciate your answer and all >> >> >> the wonderful tutorials at perlmaven, but so far I am unable to get >> >> >> this answer to work for me. My my hash %season seems to look the >> >> >> same >> >> >> as your %payload but when I try your solution only the name of the >> >> >> player is displayed. I do not use 'use Template'; in my backend >> >> >> code >> >> >> and am not really sure what the exact role of create.pl, is it for >> >> >> teaching purposes or is there a step within it that I must apply to >> >> >> get my %season to look like your %payload before I return it to my >> >> >> Dancer app? I will continue to experiment with your solution and >> >> >> try >> >> >> to find a place where I can post exactly what I am getting as a >> >> >> result. >> >> >> >> >> >> Thanks again, >> >> >> >> >> >> Richard >> >> >> >> >> >> 2020-08-23 7:18 GMT-05:00, Gabor Szabo : >> >> >> > I am not sure if this is what you meant, but using your data I >> wrote >> >> >> > two >> >> >> > examples here: >> >> >> > https://perlmaven.com/template-toolkit-hash-of-hash >> >> >> > >> >> >> > Gabor >> >> >> > >> >> >> > On Sun, Aug 23, 2020 at 12:33 AM Richard Reina >> >> >> > >> >> >> > wrote: >> >> >> > >> >> >> >> I have the following perl multidimensional hash that is passed >> from >> >> >> >> Dancer to Template Toolkit as a hash reference. I am having >> trouble >> >> >> >> figuring out how to display it in Template Toolkit. >> >> >> >> >> >> >> >> $VAR1 = { >> >> >> >> 'TylerMontgomery(2022)' => { >> >> >> >> 'so' => 1, >> >> >> >> 'bb' => 1, >> >> >> >> 'rbis' => 0, >> >> >> >> 'atbats' => 7, >> >> >> >> 'runs' => 2, >> >> >> >> 'hits' => 2 >> >> >> >> }, >> >> >> >> 'ChaseLangan(2022)' => { >> >> >> >> 'runs' => 4, >> >> >> >> 'hits' => 4, >> >> >> >> 'atbats' => 5, >> >> >> >> 'bb' => 0, >> >> >> >> 'rbis' => 2, >> >> >> >> 'so' => 1 >> >> >> >> }, >> >> >> >> 'BryceJones(2021)' => { >> >> >> >> 'hits' => 2, >> >> >> >> 'runs' => 2, >> >> >> >> 'atbats' => 4, >> >> >> >> 'bb' => 1, >> >> >> >> 'rbis' => 4, >> >> >> >> 'so' => 1 >> >> >> >> }, >> >> >> >> }; >> >> >> >> >> >> >> >> This is how I iterate it in perl. >> >> >> >> >> >> >> >> foreach my $name (sort keys %season) { >> >> >> >> printf "%-27.27s", "$name: "; >> >> >> >> foreach my $stat (sort keys %{ $season{$name} }) { >> >> >> >> printf "%-12.12s", "$stat: $season{$name}{$stat} "; >> >> >> >> ## cal. avg >> >> >> >> $season{$name}{AVG} = $season{$name}{hits} / >> >> >> >> $season{$name}{atbats}; >> >> >> >> } >> >> >> >> >> >> >> >> >> >> >> >> printf "%4s %.3f\n", "avg:", $season{$name}{AVG}; >> >> >> >> } >> >> >> >> >> >> >> >> I then pass it back to my dancer app as a ref. with return >> >> >> >> \%season; >> >> >> >> and then to template toolkit with: >> >> >> >> >> >> >> >> template 'softball.tt' => { >> >> >> >> >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> >> >> 'Season' => $season, >> >> >> >> >> >> >> >> >> >> >> >> }, {}; >> >> >> >> >> >> >> >> But I am lost trying to get it to display with template toolkit. >> >> >> >> Here's what I've tried so far. >> >> >> >> >> >> >> >>
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats >> %> >> >> >> >> Season.val.hits <% Season.value.hits %> >> >> >> >>
>> >> >> >> <% FOREACH Season = Season %> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> <% END %> >> >> >> >> >> >> >> >> Thanks for any help. >> >> >> >> _______________________________________________ >> >> >> >> dancer-users mailing list >> >> >> >> dancer-users at lists.preshweb.co.uk >> >> >> >> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> >> >> >> >> > >> >> >> >> >> > >> >> >> > >> > From gabor at szabgab.com Mon Aug 24 00:10:58 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Mon, 24 Aug 2020 07:10:58 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: Try putting that backslash back so it will be template 'results.tt' => { 'title' => 'Get Softball Season Stats', 'payload' => \%season, }, {}; Gabor On Sun, Aug 23, 2020 at 10:44 PM Richard Reina wrote: > I was merely passing it as with different var name to distinguish from > different attempts in my html. Taking out the other case, as I have > done, has no effect on the results. > > This is what is being passed the html in the paste above: > > template 'results.tt' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => %season, > > }, {}; > > And this is the result: > > > Trying with payload > TylerMontgomery(2022) ------------- TylerMontgomery(2022) : > TylerMontgomery(2022) > > Name atbats so bb rbis hits runs TylerMontgomery(2022) > > > 2020-08-23 14:22 GMT-05:00, Gabor Szabo : > > OK, so I don't understand why do you pass the same %payload 3 times, but > > you need to pass references in all 3 cases. > > > > template 'results.tt' => { > > 'title' => 'Get Softball Season Stats', > > 'games' => \%season, > > 'season' => \%season, > > 'payload' => \%season, > > 'F_NAME' => 'Geraldo', > > > > > > }, {}; > > > > On Sun, Aug 23, 2020 at 9:38 PM Richard Reina > wrote: > > > >> template 'results.tt' => { > >> > >> 'title' => 'Get Softball Season Stats', > >> 'payload' => \%season, > >> > >> }, {}; > >> > >> Results in this: > >> > >> Trying with payload > >> ------------- : > >> > >> Name atbats so bb rbis hits runs > >> > >> > >> > >> 2020-08-23 12:53 GMT-05:00, Gabor Szabo : > >> > I think you should be passing references: > >> > > >> > 'payload' => \%season, > >> > > >> > See the backslash. > >> > > >> > Gabor > >> > > >> > > >> > > >> > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina > >> wrote: > >> > > >> >> Ok, maybe I've overlooked something but here is what I get with very > >> >> simple call to a route and using very simple html. > >> >> > >> >> http://paste.scsys.co.uk/592477 > >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Mon Aug 24 00:10:58 2020 From: gabor at szabgab.com (Gabor Szabo) Date: Mon, 24 Aug 2020 07:10:58 +0300 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: Try putting that backslash back so it will be template 'results.tt' => { 'title' => 'Get Softball Season Stats', 'payload' => \%season, }, {}; Gabor On Sun, Aug 23, 2020 at 10:44 PM Richard Reina wrote: > I was merely passing it as with different var name to distinguish from > different attempts in my html. Taking out the other case, as I have > done, has no effect on the results. > > This is what is being passed the html in the paste above: > > template 'results.tt' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => %season, > > }, {}; > > And this is the result: > > > Trying with payload > TylerMontgomery(2022) ------------- TylerMontgomery(2022) : > TylerMontgomery(2022) > > Name atbats so bb rbis hits runs TylerMontgomery(2022) > > > 2020-08-23 14:22 GMT-05:00, Gabor Szabo : > > OK, so I don't understand why do you pass the same %payload 3 times, but > > you need to pass references in all 3 cases. > > > > template 'results.tt' => { > > 'title' => 'Get Softball Season Stats', > > 'games' => \%season, > > 'season' => \%season, > > 'payload' => \%season, > > 'F_NAME' => 'Geraldo', > > > > > > }, {}; > > > > On Sun, Aug 23, 2020 at 9:38 PM Richard Reina > wrote: > > > >> template 'results.tt' => { > >> > >> 'title' => 'Get Softball Season Stats', > >> 'payload' => \%season, > >> > >> }, {}; > >> > >> Results in this: > >> > >> Trying with payload > >> ------------- : > >> > >> Name atbats so bb rbis hits runs > >> > >> > >> > >> 2020-08-23 12:53 GMT-05:00, Gabor Szabo : > >> > I think you should be passing references: > >> > > >> > 'payload' => \%season, > >> > > >> > See the backslash. > >> > > >> > Gabor > >> > > >> > > >> > > >> > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina > >> wrote: > >> > > >> >> Ok, maybe I've overlooked something but here is what I get with very > >> >> simple call to a route and using very simple html. > >> >> > >> >> http://paste.scsys.co.uk/592477 > >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gatorreina at gmail.com Mon Aug 24 11:26:15 2020 From: gatorreina at gmail.com (Richard Reina) Date: Mon, 24 Aug 2020 10:26:15 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: I am going out of my mind. I have no idea what could be wrong. Below is my route (with the hash defined in it), my html and the results I get in the browser. get '/results' => sub { # Test the hash my %season= ( 'TylerMontgomery(2022)' => { 'so' => 1, 'bb' => 1, 'rbis' => 0, 'atbats' => 117, 'runs' => 2, 'hits' => 2 }, 'ChaseLangan(2022)' => { 'runs' => 4, 'hits' => 24, 'atbats' => 5, 'bb' => 0, 'rbis' => 2, 'so' => 1 }, 'BryceJones(2021)' => { 'hits' => 2, 'runs' => 2, 'atbats' => 4, 'bb' => 2, 'rbis' => 4, 'so' => 1 }, ); template 'results.tt' => { 'title' => 'Get Softball Season Stats', 'payload' => \%season, }, {}; }; ################################################ HTML ################################################ <% IF payload.size %> <% payload.size %> <% USE Dumper; Dumper.dump(payload) %>

Trying with Gabor's solution

<% FOR name IN payload.keys.sort %> <% name %> ------------- <%- FOR field IN payload.$name.keys.sort %>

Field:

<% field %> : <% payload.$name.$field -%>

Field:

<% field %> : <% payload.$name.atbats -%> <% END %> <% END %>

Trying with Ikegami's solution

<% FOREACH id IN payload.keys %> <% season = payload.$id %>

<% season.runs %>

<% season.atbats %>

<% END %>


<% USE String %> Name atbats so bb rbis hits runs <% FOR name IN payload.keys.sort %> <% fname = String.new(name) -%> <% atbats = String.new(payload.$name.atbats) -%> <% so = String.new(payload.$name.so) -%> <% bb = String.new(payload.$name.bb ) -%> <% rbis = String.new(payload.$name.rbis) -%> <% hits = String.new(payload.$name.hits) -%> <% runs = String.new(payload.$name.runs) -%> <% fname.left(22) %> <% atbats.right(3) -%> <% so.right(3) -%> <% bb.right(3) -%> <% rbis.right(3) -%> <% hits.right(3) -%> <% runs.right(3) -%> <% END %> <% END %>

Trying with Perlmonks solution

<% FOREACH brevet = payload %> brevet.key <% brevet.key %> brevet.val <% brevet.value %> brevet.$val.hits <% brevet.$value.atbats %> brevet.val.atbats <% brevet.value.runs %> brevet.val.dist <% brevet.value.hits %> <% END %>
####################################################### The results that appear in the browser ####################################################### Trying with Gabor's solution------------- Field: : Field: : Trying with Ikegami's solution Name atbats so bb rbis hits runs Trying with Perlmonks solutionHASH(0x17982b0) brevet.key brevet.val brevet.$val.hits brevet.val.atbats brevet.val.dist Powered by Dancer2 0.300004 ############################################################################################## *If I replace 'payload' => \%season, with 'payload' => %season and restart my app with plackup bin/app.psgi then the results in the browser are:* TylerMontgomery(2022) TylerMontgomery(2022) Trying with Gabor's solutionTylerMontgomery(2022) ------------- TylerMontgomery(2022) Field: : TylerMontgomery(2022) Field: : TylerMontgomery(2022) Trying with Ikegami's solutionTylerMontgomery(2022) TylerMontgomery(2022) Name atbats so bb rbis hits runs TylerMontgomery(2022) Trying with Perlmonks solutionTylerMontgomery(2022) brevet.key brevet.val brevet.$val.hits brevet.val.atbats brevet.val.dist Powered by Dancer2 0.300004 El dom., 23 ago. 2020 a las 23:11, Gabor Szabo () escribi?: > Try putting that backslash back so it will be > > template 'results.tt' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => \%season, > > }, {}; > Gabor > > On Sun, Aug 23, 2020 at 10:44 PM Richard Reina > wrote: > >> I was merely passing it as with different var name to distinguish from >> different attempts in my html. Taking out the other case, as I have >> done, has no effect on the results. >> >> This is what is being passed the html in the paste above: >> >> template 'results.tt' => { >> >> 'title' => 'Get Softball Season Stats', >> 'payload' => %season, >> >> }, {}; >> >> And this is the result: >> >> >> Trying with payload >> TylerMontgomery(2022) ------------- TylerMontgomery(2022) : >> TylerMontgomery(2022) >> >> Name atbats so bb rbis hits runs TylerMontgomery(2022) >> >> >> 2020-08-23 14:22 GMT-05:00, Gabor Szabo : >> > OK, so I don't understand why do you pass the same %payload 3 times, but >> > you need to pass references in all 3 cases. >> > >> > template 'results.tt' => { >> > 'title' => 'Get Softball Season Stats', >> > 'games' => \%season, >> > 'season' => \%season, >> > 'payload' => \%season, >> > 'F_NAME' => 'Geraldo', >> > >> > >> > }, {}; >> > >> > On Sun, Aug 23, 2020 at 9:38 PM Richard Reina >> wrote: >> > >> >> template 'results.tt' => { >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> 'payload' => \%season, >> >> >> >> }, {}; >> >> >> >> Results in this: >> >> >> >> Trying with payload >> >> ------------- : >> >> >> >> Name atbats so bb rbis hits runs >> >> >> >> >> >> >> >> 2020-08-23 12:53 GMT-05:00, Gabor Szabo : >> >> > I think you should be passing references: >> >> > >> >> > 'payload' => \%season, >> >> > >> >> > See the backslash. >> >> > >> >> > Gabor >> >> > >> >> > >> >> > >> >> > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina >> >> wrote: >> >> > >> >> >> Ok, maybe I've overlooked something but here is what I get with very >> >> >> simple call to a route and using very simple html. >> >> >> >> >> >> http://paste.scsys.co.uk/592477 >> >> >> >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From gatorreina at gmail.com Mon Aug 24 11:26:15 2020 From: gatorreina at gmail.com (Richard Reina) Date: Mon, 24 Aug 2020 10:26:15 -0500 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: I am going out of my mind. I have no idea what could be wrong. Below is my route (with the hash defined in it), my html and the results I get in the browser. get '/results' => sub { # Test the hash my %season= ( 'TylerMontgomery(2022)' => { 'so' => 1, 'bb' => 1, 'rbis' => 0, 'atbats' => 117, 'runs' => 2, 'hits' => 2 }, 'ChaseLangan(2022)' => { 'runs' => 4, 'hits' => 24, 'atbats' => 5, 'bb' => 0, 'rbis' => 2, 'so' => 1 }, 'BryceJones(2021)' => { 'hits' => 2, 'runs' => 2, 'atbats' => 4, 'bb' => 2, 'rbis' => 4, 'so' => 1 }, ); template 'results.tt' => { 'title' => 'Get Softball Season Stats', 'payload' => \%season, }, {}; }; ################################################ HTML ################################################ <% IF payload.size %> <% payload.size %> <% USE Dumper; Dumper.dump(payload) %>

Trying with Gabor's solution

<% FOR name IN payload.keys.sort %> <% name %> ------------- <%- FOR field IN payload.$name.keys.sort %>

Field:

<% field %> : <% payload.$name.$field -%>

Field:

<% field %> : <% payload.$name.atbats -%> <% END %> <% END %>

Trying with Ikegami's solution

<% FOREACH id IN payload.keys %> <% season = payload.$id %>

<% season.runs %>

<% season.atbats %>

<% END %>


<% USE String %> Name atbats so bb rbis hits runs <% FOR name IN payload.keys.sort %> <% fname = String.new(name) -%> <% atbats = String.new(payload.$name.atbats) -%> <% so = String.new(payload.$name.so) -%> <% bb = String.new(payload.$name.bb ) -%> <% rbis = String.new(payload.$name.rbis) -%> <% hits = String.new(payload.$name.hits) -%> <% runs = String.new(payload.$name.runs) -%> <% fname.left(22) %> <% atbats.right(3) -%> <% so.right(3) -%> <% bb.right(3) -%> <% rbis.right(3) -%> <% hits.right(3) -%> <% runs.right(3) -%> <% END %> <% END %>

Trying with Perlmonks solution

<% FOREACH brevet = payload %> brevet.key <% brevet.key %> brevet.val <% brevet.value %> brevet.$val.hits <% brevet.$value.atbats %> brevet.val.atbats <% brevet.value.runs %> brevet.val.dist <% brevet.value.hits %> <% END %>
####################################################### The results that appear in the browser ####################################################### Trying with Gabor's solution------------- Field: : Field: : Trying with Ikegami's solution Name atbats so bb rbis hits runs Trying with Perlmonks solutionHASH(0x17982b0) brevet.key brevet.val brevet.$val.hits brevet.val.atbats brevet.val.dist Powered by Dancer2 0.300004 ############################################################################################## *If I replace 'payload' => \%season, with 'payload' => %season and restart my app with plackup bin/app.psgi then the results in the browser are:* TylerMontgomery(2022) TylerMontgomery(2022) Trying with Gabor's solutionTylerMontgomery(2022) ------------- TylerMontgomery(2022) Field: : TylerMontgomery(2022) Field: : TylerMontgomery(2022) Trying with Ikegami's solutionTylerMontgomery(2022) TylerMontgomery(2022) Name atbats so bb rbis hits runs TylerMontgomery(2022) Trying with Perlmonks solutionTylerMontgomery(2022) brevet.key brevet.val brevet.$val.hits brevet.val.atbats brevet.val.dist Powered by Dancer2 0.300004 El dom., 23 ago. 2020 a las 23:11, Gabor Szabo () escribi?: > Try putting that backslash back so it will be > > template 'results.tt' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => \%season, > > }, {}; > Gabor > > On Sun, Aug 23, 2020 at 10:44 PM Richard Reina > wrote: > >> I was merely passing it as with different var name to distinguish from >> different attempts in my html. Taking out the other case, as I have >> done, has no effect on the results. >> >> This is what is being passed the html in the paste above: >> >> template 'results.tt' => { >> >> 'title' => 'Get Softball Season Stats', >> 'payload' => %season, >> >> }, {}; >> >> And this is the result: >> >> >> Trying with payload >> TylerMontgomery(2022) ------------- TylerMontgomery(2022) : >> TylerMontgomery(2022) >> >> Name atbats so bb rbis hits runs TylerMontgomery(2022) >> >> >> 2020-08-23 14:22 GMT-05:00, Gabor Szabo : >> > OK, so I don't understand why do you pass the same %payload 3 times, but >> > you need to pass references in all 3 cases. >> > >> > template 'results.tt' => { >> > 'title' => 'Get Softball Season Stats', >> > 'games' => \%season, >> > 'season' => \%season, >> > 'payload' => \%season, >> > 'F_NAME' => 'Geraldo', >> > >> > >> > }, {}; >> > >> > On Sun, Aug 23, 2020 at 9:38 PM Richard Reina >> wrote: >> > >> >> template 'results.tt' => { >> >> >> >> 'title' => 'Get Softball Season Stats', >> >> 'payload' => \%season, >> >> >> >> }, {}; >> >> >> >> Results in this: >> >> >> >> Trying with payload >> >> ------------- : >> >> >> >> Name atbats so bb rbis hits runs >> >> >> >> >> >> >> >> 2020-08-23 12:53 GMT-05:00, Gabor Szabo : >> >> > I think you should be passing references: >> >> > >> >> > 'payload' => \%season, >> >> > >> >> > See the backslash. >> >> > >> >> > Gabor >> >> > >> >> > >> >> > >> >> > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina >> >> wrote: >> >> > >> >> >> Ok, maybe I've overlooked something but here is what I get with very >> >> >> simple call to a route and using very simple html. >> >> >> >> >> >> http://paste.scsys.co.uk/592477 >> >> >> >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From clive at hildebrand.co.uk Mon Aug 24 11:39:45 2020 From: clive at hildebrand.co.uk (Clive Eisen) Date: Mon, 24 Aug 2020 16:39:45 +0100 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: <33F43E19-00C6-4B9A-ADE9-6F43F498E4C4@hildebrand.co.uk> You need to add template: template_toolkit engines: template: template_toolkit: start_tag: '<%' stop_tag: '%>' into environments/development.yaml ? Clive Eisen GPG: 3818B5F1 > On 24 Aug 2020, at 16:26, Richard Reina wrote: > > I am going out of my mind. I have no idea what could be wrong. > > Below is my route (with the hash defined in it), my html and the results I get in the browser. > > get '/results' => sub { > > # Test the hash > my %season= ( > 'TylerMontgomery(2022)' => { > 'so' => 1, > 'bb' => 1, > 'rbis' => 0, > 'atbats' => 117, > 'runs' => 2, > 'hits' => 2 > }, > 'ChaseLangan(2022)' => { > 'runs' => 4, > 'hits' => 24, > 'atbats' => 5, > 'bb' => 0, > 'rbis' => 2, > 'so' => 1 > }, > 'BryceJones(2021)' => { > 'hits' => 2, > 'runs' => 2, > 'atbats' => 4, > 'bb' => 2, > 'rbis' => 4, > 'so' => 1 > }, > ); > > > template 'results.tt ' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => \%season, > > }, {}; > > }; > > ################################################ > HTML > ################################################ > > > > > > > > > <% IF payload.size %> > <% payload.size %> > <% USE Dumper; Dumper.dump(payload) %> > >
>

Trying with Gabor's solution

> <% FOR name IN payload.keys.sort %> > <% name %> > ------------- > <%- FOR field IN payload.$name.keys.sort %> >

Field:

<% field %> : <% payload.$name.$field -%> >

Field:

<% field %> : <% payload.$name.atbats -%> > <% END %> > <% END %> >
> >
>

Trying with Ikegami's solution

> <% FOREACH id IN payload.keys %> > <% season = payload.$id %> >

<% season.runs %>

>

<% season.atbats %>

> <% END %> >
> >

>
> <% USE String %> > > Name atbats so bb rbis hits runs > <% FOR name IN payload.keys.sort %> > <% fname = String.new(name) -%> > <% atbats = String.new(payload.$name.atbats) -%> > <% so = String.new(payload.$name.so) -%> > <% bb = String.new(payload.$name.bb ) -%> > <% rbis = String.new(payload.$name.rbis) -%> > <% hits = String.new(payload.$name.hits) -%> > <% runs = String.new(payload.$name.runs) -%> > <% fname.left(22) %> <% atbats.right(3) -%> <% so.right(3) -%> <% bb.right(3) -%> <% rbis.right(3) -%> <% hits.right(3) -%> <% runs.right(3) -%> > <% END %> > <% END %> >
> >
>

Trying with Perlmonks solution

> <% FOREACH brevet = payload %> > brevet.key <% brevet.key %> > brevet.val <% brevet.value %> > brevet.$val.hits <% brevet.$value.atbats %> > brevet.val.atbats <% brevet.value.runs %> > brevet.val.dist <% brevet.value.hits %> > <% END %> >
> > > > ####################################################### > The results that appear in the browser > ####################################################### > Trying with Gabor's solution > > ------------- > Field: > > : > Field: > > : > Trying with Ikegami's solution > > > > > > Name atbats so bb rbis hits runs > Trying with Perlmonks solution > > HASH(0x17982b0) brevet.key brevet.val brevet.$val.hits brevet.val.atbats brevet.val.dist > Powered by Dancer2 0.300004 > ############################################################################################## > If I replace 'payload' => \%season, with 'payload' => %season and restart my app with plackup bin/app.psgi then the results in the browser are: > TylerMontgomery(2022) TylerMontgomery(2022) > Trying with Gabor's solution > > TylerMontgomery(2022) ------------- TylerMontgomery(2022) > Field: > > : TylerMontgomery(2022) > Field: > > : TylerMontgomery(2022) > Trying with Ikegami's solution > > TylerMontgomery(2022) TylerMontgomery(2022) > > > > > Name atbats so bb rbis hits runs TylerMontgomery(2022) > Trying with Perlmonks solution > > TylerMontgomery(2022) brevet.key brevet.val brevet.$val.hits brevet.val.atbats brevet.val.dist > Powered by Dancer2 0.300004 > > > > > El dom., 23 ago. 2020 a las 23:11, Gabor Szabo (>) escribi?: > Try putting that backslash back so it will be > > template 'results.tt ' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => \%season, > > }, {}; > Gabor > > On Sun, Aug 23, 2020 at 10:44 PM Richard Reina > wrote: > I was merely passing it as with different var name to distinguish from > different attempts in my html. Taking out the other case, as I have > done, has no effect on the results. > > This is what is being passed the html in the paste above: > > template 'results.tt ' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => %season, > > }, {}; > > And this is the result: > > > Trying with payload > TylerMontgomery(2022) ------------- TylerMontgomery(2022) : > TylerMontgomery(2022) > > Name atbats so bb rbis hits runs TylerMontgomery(2022) > > > 2020-08-23 14:22 GMT-05:00, Gabor Szabo >: > > OK, so I don't understand why do you pass the same %payload 3 times, but > > you need to pass references in all 3 cases. > > > > template 'results.tt ' => { > > 'title' => 'Get Softball Season Stats', > > 'games' => \%season, > > 'season' => \%season, > > 'payload' => \%season, > > 'F_NAME' => 'Geraldo', > > > > > > }, {}; > > > > On Sun, Aug 23, 2020 at 9:38 PM Richard Reina > wrote: > > > >> template 'results.tt ' => { > >> > >> 'title' => 'Get Softball Season Stats', > >> 'payload' => \%season, > >> > >> }, {}; > >> > >> Results in this: > >> > >> Trying with payload > >> ------------- : > >> > >> Name atbats so bb rbis hits runs > >> > >> > >> > >> 2020-08-23 12:53 GMT-05:00, Gabor Szabo >: > >> > I think you should be passing references: > >> > > >> > 'payload' => \%season, > >> > > >> > See the backslash. > >> > > >> > Gabor > >> > > >> > > >> > > >> > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina > > >> wrote: > >> > > >> >> Ok, maybe I've overlooked something but here is what I get with very > >> >> simple call to a route and using very simple html. > >> >> > >> >> http://paste.scsys.co.uk/592477 > >> >> > > _______________________________________________ > dancer-users mailing list > dancer-users at lists.preshweb.co.uk > https://lists.preshweb.co.uk/mailman/listinfo/dancer-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From clive at hildebrand.co.uk Mon Aug 24 11:39:45 2020 From: clive at hildebrand.co.uk (Clive Eisen) Date: Mon, 24 Aug 2020 16:39:45 +0100 Subject: [dancer-users] How tod displaye aMulti Dimesional Hash in Template Toolkit In-Reply-To: References: Message-ID: <33F43E19-00C6-4B9A-ADE9-6F43F498E4C4@hildebrand.co.uk> You need to add template: template_toolkit engines: template: template_toolkit: start_tag: '<%' stop_tag: '%>' into environments/development.yaml ? Clive Eisen GPG: 3818B5F1 > On 24 Aug 2020, at 16:26, Richard Reina wrote: > > I am going out of my mind. I have no idea what could be wrong. > > Below is my route (with the hash defined in it), my html and the results I get in the browser. > > get '/results' => sub { > > # Test the hash > my %season= ( > 'TylerMontgomery(2022)' => { > 'so' => 1, > 'bb' => 1, > 'rbis' => 0, > 'atbats' => 117, > 'runs' => 2, > 'hits' => 2 > }, > 'ChaseLangan(2022)' => { > 'runs' => 4, > 'hits' => 24, > 'atbats' => 5, > 'bb' => 0, > 'rbis' => 2, > 'so' => 1 > }, > 'BryceJones(2021)' => { > 'hits' => 2, > 'runs' => 2, > 'atbats' => 4, > 'bb' => 2, > 'rbis' => 4, > 'so' => 1 > }, > ); > > > template 'results.tt ' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => \%season, > > }, {}; > > }; > > ################################################ > HTML > ################################################ > > > > > > > > > <% IF payload.size %> > <% payload.size %> > <% USE Dumper; Dumper.dump(payload) %> > >
>

Trying with Gabor's solution

> <% FOR name IN payload.keys.sort %> > <% name %> > ------------- > <%- FOR field IN payload.$name.keys.sort %> >

Field:

<% field %> : <% payload.$name.$field -%> >

Field:

<% field %> : <% payload.$name.atbats -%> > <% END %> > <% END %> >
> >
>

Trying with Ikegami's solution

> <% FOREACH id IN payload.keys %> > <% season = payload.$id %> >

<% season.runs %>

>

<% season.atbats %>

> <% END %> >
> >

>
> <% USE String %> > > Name atbats so bb rbis hits runs > <% FOR name IN payload.keys.sort %> > <% fname = String.new(name) -%> > <% atbats = String.new(payload.$name.atbats) -%> > <% so = String.new(payload.$name.so) -%> > <% bb = String.new(payload.$name.bb ) -%> > <% rbis = String.new(payload.$name.rbis) -%> > <% hits = String.new(payload.$name.hits) -%> > <% runs = String.new(payload.$name.runs) -%> > <% fname.left(22) %> <% atbats.right(3) -%> <% so.right(3) -%> <% bb.right(3) -%> <% rbis.right(3) -%> <% hits.right(3) -%> <% runs.right(3) -%> > <% END %> > <% END %> >
> >
>

Trying with Perlmonks solution

> <% FOREACH brevet = payload %> > brevet.key <% brevet.key %> > brevet.val <% brevet.value %> > brevet.$val.hits <% brevet.$value.atbats %> > brevet.val.atbats <% brevet.value.runs %> > brevet.val.dist <% brevet.value.hits %> > <% END %> >
> > > > ####################################################### > The results that appear in the browser > ####################################################### > Trying with Gabor's solution > > ------------- > Field: > > : > Field: > > : > Trying with Ikegami's solution > > > > > > Name atbats so bb rbis hits runs > Trying with Perlmonks solution > > HASH(0x17982b0) brevet.key brevet.val brevet.$val.hits brevet.val.atbats brevet.val.dist > Powered by Dancer2 0.300004 > ############################################################################################## > If I replace 'payload' => \%season, with 'payload' => %season and restart my app with plackup bin/app.psgi then the results in the browser are: > TylerMontgomery(2022) TylerMontgomery(2022) > Trying with Gabor's solution > > TylerMontgomery(2022) ------------- TylerMontgomery(2022) > Field: > > : TylerMontgomery(2022) > Field: > > : TylerMontgomery(2022) > Trying with Ikegami's solution > > TylerMontgomery(2022) TylerMontgomery(2022) > > > > > Name atbats so bb rbis hits runs TylerMontgomery(2022) > Trying with Perlmonks solution > > TylerMontgomery(2022) brevet.key brevet.val brevet.$val.hits brevet.val.atbats brevet.val.dist > Powered by Dancer2 0.300004 > > > > > El dom., 23 ago. 2020 a las 23:11, Gabor Szabo (>) escribi?: > Try putting that backslash back so it will be > > template 'results.tt ' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => \%season, > > }, {}; > Gabor > > On Sun, Aug 23, 2020 at 10:44 PM Richard Reina > wrote: > I was merely passing it as with different var name to distinguish from > different attempts in my html. Taking out the other case, as I have > done, has no effect on the results. > > This is what is being passed the html in the paste above: > > template 'results.tt ' => { > > 'title' => 'Get Softball Season Stats', > 'payload' => %season, > > }, {}; > > And this is the result: > > > Trying with payload > TylerMontgomery(2022) ------------- TylerMontgomery(2022) : > TylerMontgomery(2022) > > Name atbats so bb rbis hits runs TylerMontgomery(2022) > > > 2020-08-23 14:22 GMT-05:00, Gabor Szabo >: > > OK, so I don't understand why do you pass the same %payload 3 times, but > > you need to pass references in all 3 cases. > > > > template 'results.tt ' => { > > 'title' => 'Get Softball Season Stats', > > 'games' => \%season, > > 'season' => \%season, > > 'payload' => \%season, > > 'F_NAME' => 'Geraldo', > > > > > > }, {}; > > > > On Sun, Aug 23, 2020 at 9:38 PM Richard Reina > wrote: > > > >> template 'results.tt ' => { > >> > >> 'title' => 'Get Softball Season Stats', > >> 'payload' => \%season, > >> > >> }, {}; > >> > >> Results in this: > >> > >> Trying with payload > >> ------------- : > >> > >> Name atbats so bb rbis hits runs > >> > >> > >> > >> 2020-08-23 12:53 GMT-05:00, Gabor Szabo >: > >> > I think you should be passing references: > >> > > >> > 'payload' => \%season, > >> > > >> > See the backslash. > >> > > >> > Gabor > >> > > >> > > >> > > >> > On Sun, Aug 23, 2020 at 8:45 PM Richard Reina > > >> wrote: > >> > > >> >> Ok, maybe I've overlooked something but here is what I get with very > >> >> simple call to a route and using very simple html. > >> >> > >> >> http://paste.scsys.co.uk/592477 > >> >> > > _______________________________________________ > dancer-users mailing list > dancer-users at lists.preshweb.co.uk > https://lists.preshweb.co.uk/mailman/listinfo/dancer-users -------------- next part -------------- An HTML attachment was scrubbed... URL:
Season.key <% Season.key %>Season.val <% Season.value %>Season.val.atbats <% Season.value.atbats >> %> >> >> >> >> Season.val.hits <% Season.value.hits %> >> >> >> >>