line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
8
|
|
|
8
|
|
101
|
use 5.006; |
|
8
|
|
|
|
|
16
|
|
2
|
8
|
|
|
8
|
|
25
|
use strict; |
|
8
|
|
|
|
|
7
|
|
|
8
|
|
|
|
|
122
|
|
3
|
8
|
|
|
8
|
|
19
|
use warnings; |
|
8
|
|
|
|
|
7
|
|
|
8
|
|
|
|
|
234
|
|
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
|
|
|
8
|
|
23
|
use base qw(EJS::Template::Base EJS::Template::IO); |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
602
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
2752
|
use EJS::Template::Parser::Context; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
1178
|
|
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
|
|
|
|
|
|
|
sub parse { |
30
|
82
|
|
|
82
|
1
|
93
|
my ($self, $input, $output) = @_; |
31
|
82
|
|
|
|
|
355
|
my ($in, $in_close) = EJS::Template::IO->input($input); |
32
|
|
|
|
|
|
|
|
33
|
82
|
|
|
|
|
89
|
my $context; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$self->input($input, sub { |
36
|
82
|
|
|
82
|
|
94
|
my ($in) = @_; |
37
|
82
|
|
|
|
|
221
|
$context = EJS::Template::Parser::Context->new($self->config); |
38
|
|
|
|
|
|
|
|
39
|
82
|
|
|
|
|
324
|
while (my $line = <$in>) { |
40
|
142
|
|
|
|
|
5202
|
$line =~ s/\r+\n?$/\n/; |
41
|
142
|
|
|
|
|
308
|
$context->read_line($line); |
42
|
|
|
|
|
|
|
} |
43
|
82
|
|
|
|
|
433
|
}); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->output($output, sub { |
46
|
82
|
|
|
82
|
|
92
|
my ($out) = @_; |
47
|
82
|
|
|
|
|
71
|
print $out $_ foreach @{$context->result}; |
|
82
|
|
|
|
|
176
|
|
48
|
82
|
|
|
|
|
1035
|
}); |
49
|
|
|
|
|
|
|
|
50
|
82
|
|
|
|
|
869
|
return 1; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 SEE ALSO |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over 4 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item * L |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=back |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |