line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::MicroTemplate::DataSectionEx; |
2
|
1
|
|
|
1
|
|
990
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
202
|
|
3
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
6
|
use base 'Text::MicroTemplate::Extended', 'Exporter'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1724
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw(render_mt); |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
15268
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
199
|
|
10
|
1
|
|
|
1
|
|
1122
|
use Encode; |
|
1
|
|
|
|
|
11673
|
|
|
1
|
|
|
|
|
102
|
|
11
|
1
|
|
|
1
|
|
1397
|
use Data::Section::Simple; |
|
1
|
|
|
|
|
528
|
|
|
1
|
|
|
|
|
263
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
4
|
|
|
4
|
1
|
25
|
my $self = shift->SUPER::new(@_); |
15
|
4
|
|
50
|
|
|
622
|
$self->{package} ||= scalar caller; |
16
|
4
|
|
|
|
|
15
|
$self->{section} = Data::Section::Simple->new( $self->{package} ); |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
|
|
31
|
$self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub build_file { |
22
|
5
|
|
|
5
|
1
|
205
|
my ($self, $file) = @_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# return cached entry |
25
|
5
|
50
|
|
|
|
14
|
if (my $e = $self->{cache}{ $file }) { |
26
|
0
|
|
|
|
|
0
|
return $e; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
5
|
|
|
|
|
12
|
my $data = $self->{section}->get_data_section($file); |
30
|
5
|
50
|
|
|
|
477
|
if ($data) { |
31
|
5
|
|
|
|
|
15
|
$self->parse(decode_utf8 $data); |
32
|
|
|
|
|
|
|
|
33
|
5
|
|
|
|
|
934
|
local $Text::MicroTemplate::_mt_setter = 'my $_mt = shift;'; |
34
|
5
|
|
|
|
|
21
|
my $f = $self->build(); |
35
|
|
|
|
|
|
|
|
36
|
5
|
50
|
|
|
|
1717
|
$self->{cache}{$file} = $f if $self->{use_cache}; |
37
|
5
|
|
|
|
|
17
|
return $f; |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
0
|
croak "could not find template file: $file in __DATA__ section"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub render_mt { |
43
|
4
|
50
|
|
4
|
1
|
2632
|
my $self = ref $_[0] ? shift : __PACKAGE__->new(package => scalar caller); |
44
|
4
|
|
|
|
|
19
|
$self->render_file(@_); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|