line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::JavaScript; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
93672
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
89
|
|
4
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
135
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Template::Plugin; |
8
|
2
|
|
|
2
|
|
13
|
use base qw(Template::Plugin); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1717
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
5393
|
use vars qw($FILTER_NAME); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
544
|
|
11
|
|
|
|
|
|
|
$FILTER_NAME = 'js'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
4
|
|
|
4
|
1
|
8227
|
my($self, $context, @args) = @_; |
15
|
4
|
|
33
|
|
|
25
|
my $name = $args[0] || $FILTER_NAME; |
16
|
4
|
|
|
|
|
23
|
$context->define_filter($name, \&encode_js, 0); |
17
|
4
|
|
|
|
|
94
|
return $self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub encode_js { |
21
|
4
|
|
|
4
|
0
|
252
|
local $_ = shift; |
22
|
4
|
50
|
|
|
|
13
|
return '' unless defined $_; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
12
|
s!\\!\\\\!g; |
25
|
4
|
|
|
|
|
32
|
s!(['"])!\\$1!g; |
26
|
4
|
|
|
|
|
19
|
s!\n!\\n!g; |
27
|
4
|
|
|
|
|
6
|
s!\f!\\f!g; |
28
|
4
|
|
|
|
|
7
|
s!\r!\\r!g; |
29
|
4
|
|
|
|
|
10
|
s!\t!\\t!g; |
30
|
4
|
|
|
|
|
11
|
s!
|
31
|
4
|
|
|
|
|
9
|
s!>!\\x3e!g; |
32
|
4
|
|
|
|
|
9
|
s!&!\\x26!g; |
33
|
4
|
|
|
|
|
16
|
$_; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
__END__ |