line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::New::File; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
506
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
93
|
|
4
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
55
|
|
5
|
3
|
|
|
3
|
|
11
|
use Carp; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
189
|
|
6
|
3
|
|
|
3
|
|
558
|
use Module::New::Meta; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
18
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %stash; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
functions { |
11
|
|
|
|
|
|
|
file => sub ($$) { |
12
|
84
|
|
|
84
|
|
171
|
my ($name, $content) = @_; |
13
|
84
|
|
|
65
|
|
1552
|
$stash{$name} = sub { $content->(@_) }; |
|
65
|
|
|
|
|
190
|
|
14
|
|
|
|
|
|
|
}, |
15
|
|
|
|
|
|
|
|
16
|
84
|
|
|
84
|
|
383
|
content => sub (&) { return shift }, |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
methods { |
20
|
|
|
|
|
|
|
render => sub { |
21
|
60
|
|
|
60
|
|
116
|
my $class = shift; |
22
|
60
|
|
|
|
|
208
|
my $context = Module::New->context; |
23
|
|
|
|
|
|
|
|
24
|
60
|
|
|
|
|
85
|
my %hash; |
25
|
60
|
|
|
|
|
224
|
while ( my ($path, $content) = each %stash ) { |
26
|
65
|
|
|
|
|
2304
|
while ( my ($name) = $path =~ /\{([A-Z_]+)\}/ ) { |
27
|
12
|
|
|
|
|
66
|
my $method = $context->can(lc $name); |
28
|
12
|
50
|
|
|
|
63
|
my $value = $method ? $context->$method : ''; |
29
|
12
|
|
|
|
|
166
|
$path =~ s/\{$name\}/$value/g; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# for backward compatibility |
33
|
65
|
|
|
|
|
151
|
my $template = $content->( $context ); |
34
|
|
|
|
|
|
|
|
35
|
65
|
|
|
|
|
215
|
$hash{$path} = $context->template->render( $template ); |
36
|
|
|
|
|
|
|
} |
37
|
60
|
|
|
|
|
117726
|
%stash = (); |
38
|
60
|
|
|
|
|
456
|
return %hash; |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |