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