line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::DataPrinter; |
2
|
2
|
|
|
2
|
|
127565
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
66
|
|
3
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
71
|
|
4
|
2
|
|
|
2
|
|
11
|
use base 'Template::Plugin'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1105
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Template Toolkit dumper plugin using Data::Printer |
7
|
|
|
|
|
|
|
our $VERSION = '0.015'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
2551
|
use HTML::FromANSI::Tiny (); |
|
2
|
|
|
|
|
6073
|
|
|
2
|
|
|
|
|
58
|
|
10
|
2
|
|
|
2
|
|
1077
|
use Hash::Merge::Simple qw< merge >; |
|
2
|
|
|
|
|
1019
|
|
|
2
|
|
|
|
|
148
|
|
11
|
2
|
|
|
2
|
|
899
|
use version 0.77; |
|
2
|
|
|
|
|
3825
|
|
|
2
|
|
|
|
|
14
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
8
|
|
|
8
|
1
|
39775
|
my ($class, $context, $params) = @_; |
15
|
|
|
|
|
|
|
|
16
|
8
|
|
|
|
|
1221
|
require Data::Printer; |
17
|
8
|
|
|
|
|
62158
|
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
|
|
|
|
|
87
|
$params->{dp}); |
24
|
8
|
|
|
|
|
252
|
Data::Printer->import(%$dp_params); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $hfat_params = merge( { |
27
|
|
|
|
|
|
|
class_prefix => 'ansi_', |
28
|
|
|
|
|
|
|
no_plain_tags => 1, |
29
|
|
|
|
|
|
|
}, |
30
|
8
|
|
|
|
|
1285
|
$params->{hfat}); |
31
|
|
|
|
|
|
|
|
32
|
8
|
|
|
|
|
198
|
my $hfat = HTML::FromANSI::Tiny->new(%$hfat_params); |
33
|
8
|
|
|
|
|
19326
|
my $self = bless { |
34
|
|
|
|
|
|
|
_CONTEXT => $context, |
35
|
|
|
|
|
|
|
hfat => $hfat, |
36
|
|
|
|
|
|
|
}, $class; |
37
|
|
|
|
|
|
|
|
38
|
8
|
|
|
|
|
41
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub dump { |
42
|
9
|
|
|
9
|
1
|
202
|
my $self = shift; |
43
|
9
|
|
|
|
|
27
|
my $text = join('', map { p($_) . "\n" } @_); |
|
15
|
|
|
|
|
24404
|
|
44
|
9
|
|
|
|
|
37119
|
return $text; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub dump_html { |
48
|
5
|
|
|
5
|
1
|
170
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
5
|
|
|
|
|
15
|
my $html = $self->_css; |
51
|
5
|
|
|
|
|
25084
|
my $text = $self->dump(@_); |
52
|
5
|
|
|
|
|
28
|
$html .= "\n" . $self->{hfat}->html($text) . ' '; |
53
|
5
|
|
|
|
|
3099
|
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
|
|
12
|
my $self = shift; |
59
|
5
|
100
|
|
|
|
23
|
return '' if $self->{done_css}; |
60
|
|
|
|
|
|
|
|
61
|
4
|
|
|
|
|
20
|
$self->{done_css} = 1; |
62
|
4
|
|
|
|
|
16
|
return $self->{hfat}->style_tag . "\n"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |