line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::DataPrinter; |
2
|
2
|
|
|
2
|
|
124620
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
11
|
use base 'Template::Plugin'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1013
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Template Toolkit dumper plugin using Data::Printer |
7
|
|
|
|
|
|
|
our $VERSION = '0.017'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
2433
|
use HTML::FromANSI::Tiny 0.104 (); |
|
2
|
|
|
|
|
6148
|
|
|
2
|
|
|
|
|
67
|
|
10
|
2
|
|
|
2
|
|
923
|
use Hash::Merge::Simple qw< merge >; |
|
2
|
|
|
|
|
970
|
|
|
2
|
|
|
|
|
137
|
|
11
|
2
|
|
|
2
|
|
768
|
use version 0.77; |
|
2
|
|
|
|
|
3728
|
|
|
2
|
|
|
|
|
15
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
8
|
|
|
8
|
1
|
40702
|
my ($class, $context, $params) = @_; |
15
|
|
|
|
|
|
|
|
16
|
8
|
|
|
|
|
1104
|
require Data::Printer; |
17
|
8
|
|
|
|
|
63020
|
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
|
|
|
|
|
90
|
$params->{dp}); |
24
|
8
|
|
|
|
|
284
|
Data::Printer->import(%$dp_params); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $hfat_params = merge( { |
27
|
|
|
|
|
|
|
class_prefix => 'ansi_', |
28
|
|
|
|
|
|
|
no_plain_tags => 1, |
29
|
|
|
|
|
|
|
}, |
30
|
8
|
|
|
|
|
1242
|
$params->{hfat}); |
31
|
|
|
|
|
|
|
|
32
|
8
|
|
|
|
|
205
|
my $hfat = HTML::FromANSI::Tiny->new(%$hfat_params); |
33
|
8
|
|
|
|
|
19761
|
my $self = bless { |
34
|
|
|
|
|
|
|
_CONTEXT => $context, |
35
|
|
|
|
|
|
|
hfat => $hfat, |
36
|
|
|
|
|
|
|
}, $class; |
37
|
|
|
|
|
|
|
|
38
|
8
|
|
|
|
|
44
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub dump { |
42
|
9
|
|
|
9
|
1
|
215
|
my $self = shift; |
43
|
9
|
|
|
|
|
28
|
my $text = join('', map { p($_) . "\n" } @_); |
|
15
|
|
|
|
|
24459
|
|
44
|
9
|
|
|
|
|
39808
|
return $text; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub dump_html { |
48
|
5
|
|
|
5
|
1
|
162
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
5
|
|
|
|
|
17
|
my $html = $self->_css; |
51
|
5
|
|
|
|
|
24966
|
my $text = $self->dump(@_); |
52
|
5
|
|
|
|
|
34
|
$html .= "\n" . $self->{hfat}->html($text) . ' '; |
53
|
5
|
|
|
|
|
3191
|
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
|
|
9
|
my $self = shift; |
59
|
5
|
100
|
|
|
|
25
|
return '' if $self->{done_css}; |
60
|
|
|
|
|
|
|
|
61
|
4
|
|
|
|
|
23
|
$self->{done_css} = 1; |
62
|
4
|
|
|
|
|
16
|
return $self->{hfat}->style_tag . "\n"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |