| blib/lib/Novel/Robot/Packer/html.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % | 
| statement | 15 | 24 | 62.5 | 
| branch | 0 | 4 | 0.0 | 
| condition | n/a | ||
| subroutine | 5 | 8 | 62.5 | 
| pod | 1 | 3 | 33.3 | 
| total | 21 | 39 | 53.8 | 
| line | stmt | bran | cond | sub | pod | time | code | 
|---|---|---|---|---|---|---|---|
| 1 | package Novel::Robot::Packer::html; | ||||||
| 2 | 1 | 1 | 6 | use strict; | |||
| 1 | 2 | ||||||
| 1 | 27 | ||||||
| 3 | 1 | 1 | 5 | use warnings; | |||
| 1 | 1 | ||||||
| 1 | 21 | ||||||
| 4 | 1 | 1 | 4 | use utf8; | |||
| 1 | 2 | ||||||
| 1 | 4 | ||||||
| 5 | |||||||
| 6 | 1 | 1 | 35 | use base 'Novel::Robot::Packer'; | |||
| 1 | 2 | ||||||
| 1 | 108 | ||||||
| 7 | 1 | 1 | 1522 | use Template; | |||
| 1 | 16335 | ||||||
| 1 | 10 | ||||||
| 8 | |||||||
| 9 | sub suffix { | ||||||
| 10 | 0 | 0 | 0 | 'html'; | |||
| 11 | } | ||||||
| 12 | |||||||
| 13 | sub main { | ||||||
| 14 | 0 | 0 | 1 | my ($self, $book, %opt) = @_; | |||
| 15 | 0 | $self->process_template($book, %opt); | |||||
| 16 | 0 | return $opt{output}; | |||||
| 17 | } | ||||||
| 18 | |||||||
| 19 | |||||||
| 20 | sub process_template { | ||||||
| 21 | 0 | 0 | 0 | my ($self, $book, %opt) = @_; | |||
| 22 | |||||||
| 23 | 0 | 0 | my $toc = $opt{with_toc} ? qq{ | ||||
| 24 | [% FOREACH r IN item_list %] | ||||||
| 25 | [% IF r.content %] | ||||||
| 26 | [% END %] | ||||||
| 27 | |||||||
| 28 | } : ''; | ||||||
| 29 | |||||||
| 30 | 0 | my $txt =<<__HTML__; | |||||
| 31 | |||||||
| 32 | |||||||
| 33 | |||||||
| 34 | |||||||
| 35 | |||||||
| 36 |  | ||||||
| 37 | |||||||
| 55 | |||||||
| 56 | |||||||
| 57 | |||||||
| 58 | |||||||
| 59 | $toc | ||||||
| 60 |  | ||||||
| 61 | [% FOREACH r IN item_list %] | ||||||
| 62 | [% IF r.content %] | ||||||
| 63 |  | ||||||
| 64 | [% r.id %]. [% r.writer %] [% r.title %]  [% r.time %] | ||||||
| 65 | [% r.content %] | ||||||
| 66 | [% END %] | ||||||
| 67 | [% END %] | ||||||
| 68 | |||||||
| 69 | |||||||
| 70 | |||||||
| 71 | __HTML__ | ||||||
| 72 | 0 | my $tt=Template->new(); | |||||
| 73 | 0 | 0 | $tt->process(\$txt, $book, $opt{output}, { binmode => ':utf8' }) || die $tt->error(), "\n"; | ||||
| 74 | } | ||||||
| 75 | |||||||
| 76 | 1; |