line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::Debug::Dancer::TemplateVariables; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Plack::Middleware::Debug::Dancer::TemplateVariables::VERSION = '0.002'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Debug and inspect your template variables for Dancer |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
967
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
9
|
1
|
|
|
1
|
|
971
|
use parent qw(Plack::Middleware::Debug::Base); |
|
1
|
|
|
|
|
330
|
|
|
1
|
|
|
|
|
6
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
45255
|
use Dancer; |
|
1
|
|
|
|
|
300002
|
|
|
1
|
|
|
|
|
8
|
|
12
|
1
|
|
|
1
|
|
1689
|
use Data::Dumper (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
308
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $env_key = 'debug.dancer.templatevariables'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub prepare_app { |
17
|
|
|
|
|
|
|
Dancer::Hook->new('before_layout_render' => sub { |
18
|
0
|
|
|
0
|
|
|
my $tokens = shift; |
19
|
0
|
|
|
|
|
|
Dancer::SharedData->request->env->{$env_key} = $tokens; |
20
|
0
|
|
|
0
|
1
|
|
}); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $list_template_dumped = __PACKAGE__->build_template(<<'EOTMPL'); |
24
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
| Key |
28
|
|
|
|
|
|
|
| Value |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
| |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
% my $i; |
33
|
|
|
|
|
|
|
% while (@{$_[0]->{list}}) { |
34
|
|
|
|
|
|
|
% my($key, $value) = splice(@{$_[0]->{list}}, 0, 2); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
| <%= $key %> |
37
|
|
|
|
|
|
|
| <%= vardump($value) %> |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
% } |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
| |
42
|
|
|
|
|
|
|
EOTMPL |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub vardump { |
45
|
0
|
|
|
0
|
0
|
|
my $scalar = shift; |
46
|
0
|
0
|
|
|
|
|
return '(undef)' unless defined $scalar; |
47
|
0
|
0
|
|
|
|
|
return "$scalar" unless ref $scalar; |
48
|
0
|
|
|
|
|
|
scalar Data::Dump::dump($scalar); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub run { |
52
|
0
|
|
|
0
|
1
|
|
my ( $self, $env, $panel ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return sub { |
55
|
0
|
|
|
0
|
|
|
my $res = shift; |
56
|
0
|
|
|
|
|
|
$panel->title('Dancer::TemplateVariables'); |
57
|
0
|
|
|
|
|
|
$panel->nav_subtitle('Dancer::TemplateVariables'); |
58
|
|
|
|
|
|
|
$panel->content( sub { |
59
|
0
|
0
|
|
|
|
|
my %vars = %{ $env->{$env_key} || {} }; |
|
0
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my @var_list = map { $_ => $vars{$_} } sort keys %vars; |
|
0
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$self->render( $list_template_dumped, { list => \@var_list } ); |
62
|
0
|
|
|
|
|
|
} ); |
63
|
0
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |