line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Inline::Mason::OO; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4996
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
53
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
998
|
use AutoLoader; |
|
1
|
|
|
|
|
1613
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
512
|
use Inline::Mason::Base; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
224
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(AUTOLOAD); |
9
|
|
|
|
|
|
|
our @ISA = qw(Inline::Mason::Base AutoLoader); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
856
|
use Text::MicroMason qw(execute); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Inline::Files::Virtual; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @files_to_load; |
16
|
|
|
|
|
|
|
sub to_load_files { |
17
|
|
|
|
|
|
|
push @files_to_load, @_; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub import { |
21
|
|
|
|
|
|
|
shift; |
22
|
|
|
|
|
|
|
my $no_autoload; |
23
|
|
|
|
|
|
|
foreach my $arg (@_){ |
24
|
|
|
|
|
|
|
$no_autoload = 1 if($arg eq 'no_autoload'); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
to_load_files((caller(0))[1]) unless $no_autoload; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
|
|
|
|
|
|
my $pkg = shift; |
31
|
|
|
|
|
|
|
my @file = @_; |
32
|
|
|
|
|
|
|
my $self = bless {} => $pkg; |
33
|
|
|
|
|
|
|
foreach my $f (grep{$_} @files_to_load, (caller(0))[1], @file){ |
34
|
|
|
|
|
|
|
$self->load_file($f); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
$self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub load_mason { |
41
|
|
|
|
|
|
|
my $self = shift; |
42
|
|
|
|
|
|
|
my %arg = @_; |
43
|
|
|
|
|
|
|
my ($pkg) = (caller(0))[0]; |
44
|
|
|
|
|
|
|
no strict; |
45
|
|
|
|
|
|
|
while(my($marker, $content) = each %arg){ |
46
|
|
|
|
|
|
|
die err_taboo($marker) if $taboo_word{$marker}; |
47
|
|
|
|
|
|
|
$self->{template}{$marker} = $content if $content; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub load_file { |
52
|
|
|
|
|
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
my $filename = shift; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my @virtual_filenames = vf_load($filename, $file_marker) or die; |
56
|
|
|
|
|
|
|
local $/; |
57
|
|
|
|
|
|
|
foreach my $vfile (@virtual_filenames){ |
58
|
|
|
|
|
|
|
my $marker = vf_marker($vfile); |
59
|
|
|
|
|
|
|
$marker =~ s/\n+//so; |
60
|
|
|
|
|
|
|
$marker =~ s/^__(.+?)__/$1/so; |
61
|
|
|
|
|
|
|
die err_taboo($marker) if $taboo_word{$marker}; |
62
|
|
|
|
|
|
|
vf_open(my $F, $vfile) or die "$! ==> $marker"; |
63
|
|
|
|
|
|
|
my $content = <$F>; |
64
|
|
|
|
|
|
|
$self->load_mason($marker, $content) if $content; |
65
|
|
|
|
|
|
|
vf_close $F; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub generate { |
70
|
|
|
|
|
|
|
my $self = shift; |
71
|
|
|
|
|
|
|
my $name = shift; |
72
|
|
|
|
|
|
|
my %args = @_; |
73
|
|
|
|
|
|
|
execute($template->{(caller(0))[0]}{$name}, %args); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub DESTROY { |
77
|
|
|
|
|
|
|
my $self = shift; |
78
|
|
|
|
|
|
|
undef $self; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub AUTOLOAD{ |
82
|
|
|
|
|
|
|
use vars '$AUTOLOAD'; |
83
|
|
|
|
|
|
|
$AUTOLOAD =~ /.+::(.+)/o; |
84
|
|
|
|
|
|
|
my $self = shift; |
85
|
|
|
|
|
|
|
my $pkg = (caller(0))[0]; |
86
|
|
|
|
|
|
|
if(defined $self->{template}{$1}){ |
87
|
|
|
|
|
|
|
execute($self->{template}{$1}, @_); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else { |
90
|
|
|
|
|
|
|
die "${pkg}::$1 does not exist.\n"; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
__END__ |