line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cake::Plugins::View;
|
2
|
1
|
|
|
1
|
|
5
|
use Cake 'Plugin';
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
620
|
use Cake::View::TT;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
7
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
508
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $template;
|
7
|
|
|
|
|
|
|
my $settings;
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub template {
|
10
|
1
|
50
|
|
1
|
0
|
4
|
return $template if $template;
|
11
|
1
|
|
33
|
|
|
12
|
$settings ||= $_[1] || settings;
|
|
|
|
33
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
14
|
$template = new Cake::View::TT({
|
14
|
|
|
|
|
|
|
path => $settings->{path},
|
15
|
|
|
|
|
|
|
layout => $settings->{layout},
|
16
|
|
|
|
|
|
|
DEBUG => $settings->{Debug}
|
17
|
|
|
|
|
|
|
});
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
5
|
return $template;
|
20
|
|
|
|
|
|
|
}
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub render {
|
23
|
1
|
|
|
1
|
0
|
1119
|
my $self = $_[0];
|
24
|
1
|
|
|
|
|
5
|
my $temp = &_render_template(@_);
|
25
|
1
|
|
|
|
|
5
|
$self->body(Encode::encode('UTF-8',$temp));
|
26
|
|
|
|
|
|
|
}
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _render_template {
|
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
4
|
my $self = shift;
|
31
|
1
|
|
|
|
|
2
|
my $file = shift;
|
32
|
1
|
|
|
|
|
2
|
my $vars = shift;
|
33
|
1
|
50
|
|
|
|
6
|
$vars = {} if !$vars;
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
###stash pass as default with Cake object as c
|
36
|
1
|
|
|
|
|
3
|
$vars = {%{$self->stash},%{$vars},c=>$self};
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
37
|
1
|
|
|
|
|
3
|
my $temp;
|
38
|
1
|
|
|
|
|
2
|
eval {
|
39
|
1
|
|
|
|
|
4
|
$temp = template->render(
|
40
|
|
|
|
|
|
|
$file,
|
41
|
|
|
|
|
|
|
$vars
|
42
|
|
|
|
|
|
|
);
|
43
|
|
|
|
|
|
|
};
|
44
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
4
|
if ($@){
|
46
|
0
|
|
|
|
|
0
|
my $error = $@;
|
47
|
|
|
|
|
|
|
##get message & line number
|
48
|
0
|
|
|
|
|
0
|
my ($msg,$l) = ($error->{message} =~ /(.*?) at .*? line (\d+)/);
|
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
open my $fh, '<', $error->{file};
|
51
|
0
|
|
|
|
|
0
|
read $fh, my $buf, $error->{pos}+1;
|
52
|
0
|
|
|
|
|
0
|
close $fh;
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#count number of lines
|
55
|
0
|
|
|
|
|
0
|
my @lines = split /\n/,$buf;
|
56
|
0
|
|
|
|
|
0
|
my $line = scalar @lines + ($l-1);
|
57
|
0
|
|
|
|
|
0
|
die {
|
58
|
|
|
|
|
|
|
caller => [
|
59
|
|
|
|
|
|
|
__PACKAGE__,
|
60
|
|
|
|
|
|
|
$error->{file},
|
61
|
|
|
|
|
|
|
$line
|
62
|
|
|
|
|
|
|
],
|
63
|
|
|
|
|
|
|
file => $error->{file},
|
64
|
|
|
|
|
|
|
pos => $error->{pos},
|
65
|
|
|
|
|
|
|
message => $msg
|
66
|
|
|
|
|
|
|
}
|
67
|
|
|
|
|
|
|
}
|
68
|
1
|
|
|
|
|
3
|
return $temp;
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub layout {
|
72
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
73
|
0
|
|
|
|
|
|
my $layout = shift;
|
74
|
0
|
|
|
|
|
|
template->{layout} = $layout;
|
75
|
0
|
|
|
|
|
|
return $self;
|
76
|
|
|
|
|
|
|
}
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
register();
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1;
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__
|