lib/Template/EmbeddedPerl/Compiled.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 4 / 4 Conditioncond 100% 5 / 5 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 100% 59 / 59 CC 6 SCAR 8.3
CC
6
Cov
100%
_execute_with_context
4.0
render
3.0
BEGIN
1.0
CRAP 2.3
« lib/Template/EmbeddedPerl/RenderContext.pm ↑ Summary examples/contacts/untyped/lib/Contacts/Untyped/App.pm »
1 package Template::EmbeddedPerl::Compiled;
2  
3 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 24 ▶use Template::EmbeddedPerl::Utils 'generate_error_message';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 236 ▶sub render {
Subroutine render: called CC=3 SCAR=11.0
Pod documented
8 236 my ($self, @args) = @_;
9 236 my $context = $self->{yat}->_new_render_context(source => $self->{source});
10 my $entry = {
11 kind => 'root',
12 identifier => $self->{identifier} || $self->{source} || '<string>',
13 source => $self->{source},
14 236 ▶ };
Condition100%5/5
$self->{'identifier'} || $self->{'source'} || '<string>'
l!l
124112
$self->{"identifier"} or $self->{"source"}
l!l&&r!l&&!r
2599112
MC/DC100%2/2
$self->{'identifier'} || $self->{'source'} || '<string>'
$self->{"identifier"} $self->{"source"}
Truth table100%3/3
A or B
A= $self->{"identifier"}B= $self->{"source"}
ABresult
1X1
011
000
15 236 return $self->_render_with_context($context, $entry, @args);
16 }
17  
18 260 ▶sub _render_with_context {
Subroutine _render_with_context: called CC=1 SCAR=0.0
19 260 my ($self, $context, $entry, @args) = @_;
20 260 ▶ return $context->execute_render($entry, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
21 260 return $self->_execute_with_context($context, @args);
22 260 });
23 }
24  
25 376 ▶sub _execute_with_context {
Subroutine _execute_with_context: called CC=4 SCAR=13.9
26 376 my ($self, $context, @args) = @_;
27 376 my $frame = $context->frame;
28 376 my $output;
29 my $ok;
30 376 my $error;
31 {
32 24 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
33 376 local $Template::EmbeddedPerl::ACTIVE_RENDERER = $context;
34 376 $ok = eval {
35 376 $output = $self->{code}->($context, @args);
36 290 my $layouts = $frame->take_layouts;
37 290 for my $layout (reverse @$layouts) {
38 36 my ($identifier, $layout_args) = @$layout;
39 36 ▶ $output = $frame->with_body($output, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
40 36 return $context->render_file('layout', $identifier, @$layout_args);
41 36 });
42 }
43 287 1;
44 };
45 376 ▶ $error = $@ unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 89 287 376
46 }
47 376 ▶ $ok or do {
Branch: 1 branch
BranchTrueFalseTotal
$ok or do { die generate_error_message($error, $self->{"template"}, $self->{"source"}) } 287 89 376
48 89 die generate_error_message($error, $self->{template}, $self->{source});
49 };
50 287 return $output;
51 }
52  
53 24 1;
54  
55 =head1 NAME
56  
57 Template::EmbeddedPerl::Compiled - Compiled template
58  
59 =head1 DESCRIPTION
60  
61 This module is used internally by L<Template::EmbeddedPerl> to represent a compiled template. It is not intended to be used directly.
62  
63 =head1 METHODS
64  
65 =head2 render
66  
67 my $output = $compiled->render(@args);
68  
69 Render the template with the given arguments.
70  
71 =head1 SEE ALSO
72
73 L<Template::EmbeddedPerl>
74  
75 =head1 AUTHOR
76
77 See L<Template::EmbeddedPerl>
78
79 =head1 COPYRIGHT & LICENSE
80
81 See L<Template::EmbeddedPerl>
82
83 =cut
« lib/Template/EmbeddedPerl/RenderContext.pm ↑ Summary examples/contacts/untyped/lib/Contacts/Untyped/App.pm »