line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::New::File;
|
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
41511
|
use strict;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
95
|
|
4
|
3
|
|
|
3
|
|
13
|
use warnings;
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
77
|
|
5
|
3
|
|
|
3
|
|
17
|
use Carp;
|
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
178
|
|
6
|
3
|
|
|
3
|
|
829
|
use Module::New::Meta;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
17
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %stash;
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
functions {
|
11
|
|
|
|
|
|
|
file => sub ($$) {
|
12
|
86
|
|
|
86
|
|
125
|
my ($name, $content) = @_;
|
13
|
86
|
|
|
65
|
|
1794
|
$stash{$name} = sub { $content->(@_) };
|
|
65
|
|
|
|
|
132
|
|
14
|
|
|
|
|
|
|
},
|
15
|
|
|
|
|
|
|
|
16
|
86
|
|
|
86
|
|
340
|
content => sub (&) { return shift },
|
17
|
|
|
|
|
|
|
};
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
methods {
|
20
|
|
|
|
|
|
|
render => sub {
|
21
|
60
|
|
|
60
|
|
77
|
my $class = shift;
|
22
|
60
|
|
|
|
|
155
|
my $context = Module::New->context;
|
23
|
|
|
|
|
|
|
|
24
|
60
|
|
|
|
|
62
|
my %hash;
|
25
|
60
|
|
|
|
|
144
|
while ( my ($path, $content) = each %stash ) {
|
26
|
65
|
|
|
|
|
819
|
while ( my ($name) = $path =~ /\{([A-Z_]+)\}/ ) {
|
27
|
12
|
|
|
|
|
63
|
my $method = $context->can(lc $name);
|
28
|
12
|
50
|
|
|
|
51
|
my $value = $method ? $context->$method : '';
|
29
|
12
|
|
|
|
|
127
|
$path =~ s/\{$name\}/$value/g;
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# for backward compatibility
|
33
|
65
|
|
|
|
|
101
|
my $template = $content->( $context );
|
34
|
|
|
|
|
|
|
|
35
|
65
|
|
|
|
|
147
|
$hash{$path} = $context->template->render( $template );
|
36
|
|
|
|
|
|
|
}
|
37
|
60
|
|
|
|
|
84519
|
%stash = ();
|
38
|
60
|
|
|
|
|
277
|
return %hash;
|
39
|
|
|
|
|
|
|
},
|
40
|
|
|
|
|
|
|
};
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1;
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__
|