| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Template::Plugin::DataPrinter; |
|
2
|
2
|
|
|
2
|
|
129000
|
use strict; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
59
|
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
15
|
|
|
|
2
|
|
|
|
|
55
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use base 'Template::Plugin'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1016
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Template Toolkit dumper plugin using Data::Printer |
|
7
|
|
|
|
|
|
|
our $VERSION = '0.016'; # VERSION |
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
2402
|
use HTML::FromANSI::Tiny (); |
|
|
2
|
|
|
|
|
6164
|
|
|
|
2
|
|
|
|
|
61
|
|
|
10
|
2
|
|
|
2
|
|
951
|
use Hash::Merge::Simple qw< merge >; |
|
|
2
|
|
|
|
|
1123
|
|
|
|
2
|
|
|
|
|
121
|
|
|
11
|
2
|
|
|
2
|
|
854
|
use version 0.77; |
|
|
2
|
|
|
|
|
3882
|
|
|
|
2
|
|
|
|
|
14
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
|
14
|
8
|
|
|
8
|
1
|
36637
|
my ($class, $context, $params) = @_; |
|
15
|
|
|
|
|
|
|
|
|
16
|
8
|
|
|
|
|
1605
|
require Data::Printer; |
|
17
|
8
|
|
|
|
|
63238
|
Data::Printer->VERSION(1.0.0); |
|
18
|
|
|
|
|
|
|
my $dp_params = merge( { |
|
19
|
|
|
|
|
|
|
colored => 1, |
|
20
|
|
|
|
|
|
|
return_value => 'dump', |
|
21
|
|
|
|
|
|
|
use_prototypes => 0, |
|
22
|
|
|
|
|
|
|
}, |
|
23
|
8
|
|
|
|
|
101
|
$params->{dp}); |
|
24
|
8
|
|
|
|
|
264
|
Data::Printer->import(%$dp_params); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $hfat_params = merge( { |
|
27
|
|
|
|
|
|
|
class_prefix => 'ansi_', |
|
28
|
|
|
|
|
|
|
no_plain_tags => 1, |
|
29
|
|
|
|
|
|
|
}, |
|
30
|
8
|
|
|
|
|
1438
|
$params->{hfat}); |
|
31
|
|
|
|
|
|
|
|
|
32
|
8
|
|
|
|
|
210
|
my $hfat = HTML::FromANSI::Tiny->new(%$hfat_params); |
|
33
|
8
|
|
|
|
|
20635
|
my $self = bless { |
|
34
|
|
|
|
|
|
|
_CONTEXT => $context, |
|
35
|
|
|
|
|
|
|
hfat => $hfat, |
|
36
|
|
|
|
|
|
|
}, $class; |
|
37
|
|
|
|
|
|
|
|
|
38
|
8
|
|
|
|
|
37
|
return $self; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub dump { |
|
42
|
9
|
|
|
9
|
1
|
179
|
my $self = shift; |
|
43
|
9
|
|
|
|
|
22
|
my $text = join('', map { p($_) . "\n" } @_); |
|
|
15
|
|
|
|
|
23786
|
|
|
44
|
9
|
|
|
|
|
36603
|
return $text; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub dump_html { |
|
48
|
5
|
|
|
5
|
1
|
170
|
my $self = shift; |
|
49
|
|
|
|
|
|
|
|
|
50
|
5
|
|
|
|
|
14
|
my $html = $self->_css; |
|
51
|
5
|
|
|
|
|
25266
|
my $text = $self->dump(@_); |
|
52
|
5
|
|
|
|
|
43
|
$html .= "\n" . $self->{hfat}->html($text) . ''; |
|
53
|
5
|
|
|
|
|
3015
|
return $html; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _css { |
|
57
|
|
|
|
|
|
|
# Short of a better plan, emit the css on-demand before the first dump_html |
|
58
|
5
|
|
|
5
|
|
8
|
my $self = shift; |
|
59
|
5
|
100
|
|
|
|
22
|
return '' if $self->{done_css}; |
|
60
|
|
|
|
|
|
|
|
|
61
|
4
|
|
|
|
|
18
|
$self->{done_css} = 1; |
|
62
|
4
|
|
|
|
|
14
|
return $self->{hfat}->style_tag . "\n"; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |