line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Capture; |
2
|
2
|
|
|
2
|
|
585409
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
75
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
68
|
|
4
|
2
|
|
|
2
|
|
10
|
use base qw(Template::Plugin); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
1867
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $FILTER_NAME = 'capture'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
3
|
|
|
3
|
1
|
11118
|
my ($class, $context, @args) = @_; |
12
|
3
|
|
|
|
|
11
|
my $self = bless {}, $class; |
13
|
3
|
|
33
|
|
|
16
|
my $name = $args[0] || $FILTER_NAME; |
14
|
3
|
|
|
|
|
12
|
$context->define_filter($name, $self->_filter, 1); |
15
|
3
|
|
|
|
|
100
|
$self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _filter { |
19
|
3
|
|
|
3
|
|
6
|
my $self = shift; |
20
|
|
|
|
|
|
|
return sub { |
21
|
4
|
|
|
4
|
|
182
|
my ($context, $name) = @_; |
22
|
4
|
50
|
|
|
|
13
|
$self->throw('no name specified') unless defined $name; |
23
|
|
|
|
|
|
|
return sub { |
24
|
4
|
|
|
|
|
71
|
my $text = shift; |
25
|
4
|
|
|
|
|
36
|
$context->{STASH}->set($name, $text); |
26
|
4
|
|
|
|
|
21
|
return ''; |
27
|
|
|
|
|
|
|
} |
28
|
3
|
|
|
|
|
29
|
}; |
|
4
|
|
|
|
|
23
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub throw { |
32
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
33
|
0
|
|
|
|
|
|
die(Template::Exception->new('Capture', join('', @_))); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
__END__ |