line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Dumpvar; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Template::Plugin::Dumpvar - Dump template data in the same style as the |
8
|
|
|
|
|
|
|
debugger |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
[% USE Dumpvar %] |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
[% Dumpvar.dump(this) %] |
15
|
|
|
|
|
|
|
[% Dumpvar.dump_html(theother) %] |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
When dumping data in templates, the obvious first choice is to use the |
20
|
|
|
|
|
|
|
L plugin L. But personally, I think |
21
|
|
|
|
|
|
|
the layout is ugly and hard to read. It's designed to be parsed back in by |
22
|
|
|
|
|
|
|
perl, not to necesarily be easy on the eye. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The dump style used in the debugger, however, IS designed to be easier on |
25
|
|
|
|
|
|
|
the eye. The dumpvar.pl script it uses to do this has been cloned for general |
26
|
|
|
|
|
|
|
use as L. This module is a drop in replacement for |
27
|
|
|
|
|
|
|
Template::Plugin::Dumper that uses Devel::Dumpvar in place of Data::Dumper. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The only difference is that this module only dumps one scalar, reference, or |
30
|
|
|
|
|
|
|
object at a time. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
|
1198
|
use 5.005; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
42
|
|
37
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
38
|
1
|
|
|
1
|
|
881
|
use Devel::Dumpvar (); |
|
1
|
|
|
|
|
2777
|
|
|
1
|
|
|
|
|
24
|
|
39
|
1
|
|
|
1
|
|
10
|
use base 'Template::Plugin'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1098
|
|
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
6306
|
use vars qw{$VERSION}; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
42
|
|
|
|
|
|
|
BEGIN { |
43
|
1
|
|
|
1
|
|
206
|
$VERSION = '1.03'; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
##################################################################### |
51
|
|
|
|
|
|
|
# Constructor |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub new { |
54
|
0
|
|
0
|
0
|
1
|
|
my $class = ref $_[0] || $_[0]; |
55
|
0
|
|
|
|
|
|
bless { |
56
|
|
|
|
|
|
|
Dumpvar => Devel::Dumpvar->new( to => 'return' ), |
57
|
|
|
|
|
|
|
}, $class; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=pod |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 dump $something |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Dumps a single structure via L. Does not escape for HTML. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub dump { |
69
|
0
|
|
|
0
|
1
|
|
$_[0]->{Dumpvar}->dump( $_[1] ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 dump_html $something |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
As above, but also escapes and formats for HTML |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub dump_html { |
81
|
0
|
0
|
|
0
|
1
|
|
$_ = $_[0]->dump($_[1]) or return $_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Escape for HTML |
84
|
0
|
|
|
|
|
|
s/&/&/g; |
85
|
0
|
|
|
|
|
|
s/</g; |
86
|
0
|
|
|
|
|
|
s/>/>/g; |
87
|
0
|
|
|
|
|
|
s/\n/ \n/g; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$_; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SUPPORT |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Bugs should be submitted via the CPAN bug tracker, located at |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
For other issues, or commercial enhancement or support, contact the author. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 COPYRIGHT |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Copyright 2004 - 2008 Adam Kennedy. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This program is free software; you can redistribute |
113
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The full text of the license can be found in the |
116
|
|
|
|
|
|
|
LICENSE file included with this module. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |