line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::New::File;
|
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
915
|
use strict;
|
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
81
|
|
4
|
3
|
|
|
3
|
|
9
|
use warnings;
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
56
|
|
5
|
3
|
|
|
3
|
|
16
|
use Carp;
|
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
110
|
|
6
|
3
|
|
|
3
|
|
303
|
use Module::New::Meta;
|
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
11
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %stash;
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
functions {
|
11
|
|
|
|
|
|
|
file => sub ($$) {
|
12
|
86
|
|
|
86
|
|
114
|
my ($name, $content) = @_;
|
13
|
86
|
|
|
65
|
|
1245
|
$stash{$name} = sub { $content->(@_) };
|
|
65
|
|
|
|
|
125
|
|
14
|
|
|
|
|
|
|
},
|
15
|
|
|
|
|
|
|
|
16
|
86
|
|
|
86
|
|
280
|
content => sub (&) { return shift },
|
17
|
|
|
|
|
|
|
};
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
methods {
|
20
|
|
|
|
|
|
|
render => sub {
|
21
|
60
|
|
|
60
|
|
75
|
my $class = shift;
|
22
|
60
|
|
|
|
|
131
|
my $context = Module::New->context;
|
23
|
|
|
|
|
|
|
|
24
|
60
|
|
|
|
|
77
|
my %hash;
|
25
|
60
|
|
|
|
|
153
|
while ( my ($path, $content) = each %stash ) {
|
26
|
65
|
|
|
|
|
1630
|
while ( my ($name) = $path =~ /\{([A-Z_]+)\}/ ) {
|
27
|
12
|
|
|
|
|
54
|
my $method = $context->can(lc $name);
|
28
|
12
|
50
|
|
|
|
48
|
my $value = $method ? $context->$method : '';
|
29
|
12
|
|
|
|
|
133
|
$path =~ s/\{$name\}/$value/g;
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# for backward compatibility
|
33
|
65
|
|
|
|
|
111
|
my $template = $content->( $context );
|
34
|
|
|
|
|
|
|
|
35
|
65
|
|
|
|
|
180
|
$hash{$path} = $context->template->render( $template );
|
36
|
|
|
|
|
|
|
}
|
37
|
60
|
|
|
|
|
89133
|
%stash = ();
|
38
|
60
|
|
|
|
|
268
|
return %hash;
|
39
|
|
|
|
|
|
|
},
|
40
|
|
|
|
|
|
|
};
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1;
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__
|