From 3cf4fc648c34804ce1314aa0a0f3464851830b48 Mon Sep 17 00:00:00 2001 From: Gustav Eek Date: Mon, 6 Jan 2020 11:21:08 +0100 Subject: Debug. Plugin. Add debug and exploring items --- .ikiwiki/IkiWiki/Plugin/pandoc.pm | 55 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/.ikiwiki/IkiWiki/Plugin/pandoc.pm b/.ikiwiki/IkiWiki/Plugin/pandoc.pm index dca28c5..573617a 100755 --- a/.ikiwiki/IkiWiki/Plugin/pandoc.pm +++ b/.ikiwiki/IkiWiki/Plugin/pandoc.pm @@ -1,5 +1,7 @@ #!/usr/bin/env perl +$DB::single = 1; + package IkiWiki::Plugin::pandoc; use warnings; @@ -603,6 +605,23 @@ sub htmlize ($@) { $have_bibl = 1 if $k eq 'references'; $pagestate{$page}{meta}{$k} = $list_meta{$k}; $pagestate{$page}{meta}{"pandoc_$k"} = $list_meta{$k}; + + # DEBUG + # if (ref $list_meta{$k} eq 'ARRAY') {print "D: $k is ARRAY.", "\n";} + # else {print "D: $k is not array.", "\n";} + # if ($k eq 'references') { + # print "D: Found, ", ref $meta->{$k}, ", ", ref $list_meta{$k}, ", ", + # keys $meta->{$k}->%*, ".\n"; + # my @tmp_references; + # foreach my $item ($list_meta{$k}->@*) { + # print "D: Found $item", ".\n"; + # push @tmp_references, map { $_ => $l{$_}; + # } + # $pagestate{$page}{meta}{"pandoc_$k"} = @tmp_references; + # print "D: Sent as pandoc_$k, ", @tmp_references, ".\n"; + # } + # END + } # Try to add other keys as scalars, with pandoc_ prefix only. foreach my $k (keys %$meta) { @@ -621,7 +640,7 @@ sub htmlize ($@) { } # DEBUG - $pagestate{$page}{meta}{fripost_debug_label_1} = 'fripost debug value'; + $pagestate{$page}{meta}{fripost_debug_outer} = 'added in plugin, forced'; # END # The bibliography may be set in a Meta block in the page or in the .setup file. @@ -758,6 +777,40 @@ sub pagetemplate (@) { print "D: pandoc:pagetemplate: Run for $page and $filenamebase \n"; # END + # DEBUG compare with https://metacpan.org/pod/HTML::Template#TMPL_LOOP + if ($page eq "test") { + $template->param( + EMPLOYEE_INFO => [ + {name => 'Sam', job => 'programmer'}, + {name => 'Steve', job => 'soda jerk'}]); + + # a couple of arrays of data to put in a loop: + my @words = qw(I Am Cool); + my @numbers = qw(1 2 3); + my @loop_data = (); # initialize an array to hold your loop + + while (@words and @numbers) { + my %row_data; # get a fresh hash for the row data + + # fill in this row + $row_data{WORD} = shift @words; + $row_data{NUMBER} = shift @numbers; + + # the crucial step - push a reference to this row into the loop! + push(@loop_data, \%row_data); + } + # HERE! + $template->param(THIS_LOOP => \@loop_data); + if ($pagestate{$page}{meta}{'pandoc_references'}) { + my @more_ref = $pagestate{$page}{meta}{'pandoc_references'}->@*; + my $ref = $pagestate{$page}{meta}{'pandoc_references'}; + my $k = 'pandoc_references'; + $template->param('more_pandoc_references' => \@more_ref); + #$template->param($k => $pagestate{$page}{meta}{$k}); + } + } + # END + foreach my $k (keys %{$pagestate{$page}{meta}}) { next unless (grep {/^$k$/} ( -- cgit v1.2.3