line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
8
|
|
|
8
|
|
103
|
use 5.006; |
|
8
|
|
|
|
|
17
|
|
2
|
8
|
|
|
8
|
|
22
|
use strict; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
114
|
|
3
|
8
|
|
|
8
|
|
20
|
use warnings; |
|
8
|
|
|
|
|
5
|
|
|
8
|
|
|
|
|
339
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
EJS::Template::Runtime - Default functions that can be invoked from JavaScript |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package EJS::Template::Runtime; |
12
|
8
|
|
|
8
|
|
27
|
use base 'EJS::Template::Base'; |
|
8
|
|
|
|
|
5
|
|
|
8
|
|
|
|
|
475
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
3418
|
use URI::Escape; |
|
8
|
|
|
|
|
7666
|
|
|
8
|
|
|
|
|
2640
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EJS_FUNCTIONS = qw( |
17
|
|
|
|
|
|
|
concat |
18
|
|
|
|
|
|
|
escapeHTML |
19
|
|
|
|
|
|
|
escapeXML |
20
|
|
|
|
|
|
|
escapeURI |
21
|
|
|
|
|
|
|
escapeQuote |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our %ESCAPES = qw( |
25
|
|
|
|
|
|
|
raw concat |
26
|
|
|
|
|
|
|
html escapeHTML |
27
|
|
|
|
|
|
|
xml escapeXML |
28
|
|
|
|
|
|
|
uri escapeURI |
29
|
|
|
|
|
|
|
quote escapeQuote |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 Methods |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 make_map |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub make_map { |
39
|
63
|
|
|
63
|
1
|
81
|
my ($self) = @_; |
40
|
63
|
|
33
|
|
|
157
|
my $class = ref $self || $self; |
41
|
63
|
|
|
|
|
74
|
my $map = {}; |
42
|
|
|
|
|
|
|
|
43
|
63
|
|
|
|
|
121
|
for my $name (@EJS_FUNCTIONS) { |
44
|
315
|
|
|
|
|
229
|
$map->{$name} = \&{$class.'::'.$name}; |
|
315
|
|
|
|
|
802
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
63
|
|
|
|
|
217
|
return $map; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 concat |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub concat { |
55
|
1
|
|
|
1
|
1
|
224
|
return join('', @_); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 escapeHTML |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $html_map = { |
63
|
|
|
|
|
|
|
'<' => '<', |
64
|
|
|
|
|
|
|
'>' => '>', |
65
|
|
|
|
|
|
|
'"' => '"', |
66
|
|
|
|
|
|
|
"'" => ''', |
67
|
|
|
|
|
|
|
'&' => '&', |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub escapeHTML { |
71
|
|
|
|
|
|
|
return join('', map { |
72
|
2
|
|
|
2
|
1
|
450
|
s/([<>&"'])/$html_map->{$1}/g; |
|
2
|
|
|
|
|
5
|
|
73
|
2
|
|
|
|
|
53
|
$_; |
74
|
|
|
|
|
|
|
} @_); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 escapeXML |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $xml_map = { |
82
|
|
|
|
|
|
|
'<' => '<', |
83
|
|
|
|
|
|
|
'>' => '>', |
84
|
|
|
|
|
|
|
'"' => '"', |
85
|
|
|
|
|
|
|
"'" => ''', |
86
|
|
|
|
|
|
|
'&' => '&', |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub escapeXML { |
90
|
|
|
|
|
|
|
return join('', map { |
91
|
0
|
|
|
0
|
1
|
0
|
s/([<>&"'])/$xml_map->{$1}/g; |
|
0
|
|
|
|
|
0
|
|
92
|
0
|
|
|
|
|
0
|
$_; |
93
|
|
|
|
|
|
|
} @_); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 escapeURI |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub escapeURI { |
101
|
1
|
|
|
1
|
1
|
534
|
return join('', map {uri_escape($_)} @_); |
|
1
|
|
|
|
|
5
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 escapeQuote |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub escapeQuote { |
109
|
|
|
|
|
|
|
return join('', map { |
110
|
1
|
|
|
1
|
1
|
239
|
s/(["'])/\\$1/g; |
|
1
|
|
|
|
|
4
|
|
111
|
1
|
|
|
|
|
16
|
$_; |
112
|
|
|
|
|
|
|
} @_); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SEE ALSO |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 4 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * L |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |