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
|
|
22
|
use warnings; |
|
8
|
|
|
|
|
6
|
|
|
8
|
|
|
|
|
235
|
|
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
|
|
58
|
use base qw(EJS::Template::Base EJS::Template::IO); |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
635
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
2802
|
use EJS::Template::Parser::Context; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
1193
|
|
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
|
83
|
|
|
83
|
1
|
98
|
my ($self, $input, $output) = @_; |
31
|
83
|
|
|
|
|
346
|
my ($in, $in_close) = EJS::Template::IO->input($input); |
32
|
|
|
|
|
|
|
|
33
|
83
|
|
|
|
|
84
|
my $context; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$self->input($input, sub { |
36
|
83
|
|
|
83
|
|
101
|
my ($in) = @_; |
37
|
83
|
|
|
|
|
224
|
$context = EJS::Template::Parser::Context->new($self->config); |
38
|
|
|
|
|
|
|
|
39
|
83
|
|
|
|
|
356
|
while (my $line = <$in>) { |
40
|
143
|
|
|
|
|
5119
|
$line =~ s/\r+\n?$/\n/; |
41
|
143
|
|
|
|
|
288
|
$context->read_line($line); |
42
|
|
|
|
|
|
|
} |
43
|
83
|
|
|
|
|
454
|
}); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->output($output, sub { |
46
|
83
|
|
|
83
|
|
98
|
my ($out) = @_; |
47
|
83
|
|
|
|
|
75
|
print $out $_ foreach @{$context->result}; |
|
83
|
|
|
|
|
165
|
|
48
|
83
|
|
|
|
|
1040
|
}); |
49
|
|
|
|
|
|
|
|
50
|
83
|
|
|
|
|
891
|
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; |