Template/Parser.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 100% 40 / 40 CC 3 SCAR 3.4
CC
3
Cov
100%
__ANON__
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.4
« Template/Runtime.pm ↑ Summary
1 8 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 EJS::Template::Parser - Parser module for EJS::Template
8  
9 =cut
10  
11 package EJS::Template::Parser;
12 8 ▶use base qw(EJS::Template::Base EJS::Template::IO);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 8 ▶use EJS::Template::Parser::Context;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 =head1 Methods
17  
18 =head2 parse
19  
20 Parses EJS source and generates JavaScript code.
21  
22 $parser->parser($input, $output);
23  
24 The C<$input> is used as the EJS source code, and the generated JavaScript code
25 is written out to C<$output>.
26  
27 =cut
28  
29 83 ▶sub parse {
Subroutine parse: called CC=1 SCAR=0.0
Pod documented
30 83 my ($self, $input, $output) = @_;
31 83 my ($in, $in_close) = EJS::Template::IO->input($input);
32
33 83 my $context;
34  
35 83 ▶ $self->input($input, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
36 83 my ($in) = @_;
37 83 $context = EJS::Template::Parser::Context->new($self->config);
38
39 83 ▶ while (my $line = <$in>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $in)) 143 83 226
40 143 $line =~ s/\r+\n?$/\n/;
41 143 $context->read_line($line);
42 }
43 83 });
44  
45 83 ▶ $self->output($output, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
46 83 my ($out) = @_;
47 83 print $out $_ foreach @{$context->result};
48 83 });
49
50 83 return 1;
51 }
52  
53 =head1 SEE ALSO
54  
55 =over 4
56  
57 =item * L<EJS::Template>
58  
59 =back
60  
61 =cut
62  
63 8 1;
« Template/Runtime.pm ↑ Summary