line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 1998-2005 by Jonathan Swartz. All rights reserved. |
2
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it |
3
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package HTML::Mason::ComponentSource; |
6
|
|
|
|
|
|
|
$HTML::Mason::ComponentSource::VERSION = '1.59'; |
7
|
33
|
|
|
33
|
|
223
|
use strict; |
|
33
|
|
|
|
|
69
|
|
|
33
|
|
|
|
|
950
|
|
8
|
33
|
|
|
33
|
|
164
|
use warnings; |
|
33
|
|
|
|
|
66
|
|
|
33
|
|
|
|
|
820
|
|
9
|
33
|
|
|
33
|
|
174
|
use File::Basename; |
|
33
|
|
|
|
|
72
|
|
|
33
|
|
|
|
|
2052
|
|
10
|
33
|
|
|
33
|
|
213
|
use File::Spec; |
|
33
|
|
|
|
|
54
|
|
|
33
|
|
|
|
|
1177
|
|
11
|
33
|
|
|
33
|
|
196
|
use HTML::Mason::Exceptions( abbr => [qw(param_error error)] ); |
|
33
|
|
|
|
|
65
|
|
|
33
|
|
|
|
|
329
|
|
12
|
33
|
|
|
33
|
|
226
|
use Params::Validate qw(:all); |
|
33
|
|
|
|
|
75
|
|
|
33
|
|
|
|
|
7237
|
|
13
|
|
|
|
|
|
|
Params::Validate::validation_options( on_fail => sub { param_error join '', @_ } ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# for reference later |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# BEGIN |
18
|
|
|
|
|
|
|
# { |
19
|
|
|
|
|
|
|
# __PACKAGE__->valid_params |
20
|
|
|
|
|
|
|
# ( |
21
|
|
|
|
|
|
|
# comp_id => { type => SCALAR | UNDEF, public => 0 }, |
22
|
|
|
|
|
|
|
# friendly_name => { type => SCALAR, public => 0 }, |
23
|
|
|
|
|
|
|
# last_modified => { type => SCALAR, public => 0 }, |
24
|
|
|
|
|
|
|
# comp_path => { type => SCALAR, public => 0 }, |
25
|
|
|
|
|
|
|
# comp_class => { isa => 'HTML::Mason::Component', |
26
|
|
|
|
|
|
|
# default => 'HTML::Mason::Component', |
27
|
|
|
|
|
|
|
# public => 0 }, |
28
|
|
|
|
|
|
|
# extra => { type => HASHREF, default => {}, public => 0 }, |
29
|
|
|
|
|
|
|
# source_callback => { type => CODEREF, public => 0 }, |
30
|
|
|
|
|
|
|
# ); |
31
|
|
|
|
|
|
|
# } |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use HTML::Mason::MethodMaker |
34
|
33
|
|
|
|
|
264
|
( read_only => [ qw( comp_id |
35
|
|
|
|
|
|
|
friendly_name |
36
|
|
|
|
|
|
|
last_modified |
37
|
|
|
|
|
|
|
comp_path |
38
|
|
|
|
|
|
|
comp_class |
39
|
|
|
|
|
|
|
extra |
40
|
|
|
|
|
|
|
) ], |
41
|
33
|
|
|
33
|
|
290
|
); |
|
33
|
|
|
|
|
94
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my %defaults = ( comp_class => 'HTML::Mason::Component' ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new |
46
|
|
|
|
|
|
|
{ |
47
|
1145
|
|
|
1145
|
1
|
2415
|
my $class = shift; |
48
|
|
|
|
|
|
|
|
49
|
1145
|
|
|
|
|
11039
|
return bless { %defaults, @_ }, $class |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub comp_source_ref |
53
|
|
|
|
|
|
|
{ |
54
|
548
|
|
|
548
|
0
|
1164
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
548
|
|
|
|
|
972
|
my $source = eval { $self->{source_callback}->() }; |
|
548
|
|
|
|
|
2103
|
|
57
|
|
|
|
|
|
|
|
58
|
548
|
|
|
|
|
2739
|
rethrow_exception $@; |
59
|
|
|
|
|
|
|
|
60
|
547
|
50
|
|
|
|
1383
|
unless ( defined $source ) |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
|
|
0
|
error "source callback returned no source for $self->{friendly_name} component"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
547
|
100
|
|
|
|
1453
|
my $sourceref = ref($source) ? $source : \$source; |
66
|
547
|
|
|
|
|
2128
|
return $sourceref; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
30
|
|
|
30
|
1
|
149
|
sub comp_source { ${shift()->comp_source_ref} } |
|
30
|
|
|
|
|
75
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub object_code |
72
|
|
|
|
|
|
|
{ |
73
|
29
|
|
|
29
|
1
|
60
|
my $self = shift; |
74
|
29
|
|
|
|
|
631
|
my %p = validate( @_, { compiler => { isa => 'HTML::Mason::Compiler' } } ); |
75
|
|
|
|
|
|
|
|
76
|
29
|
|
|
|
|
188
|
return $p{compiler}->compile( comp_source => $self->comp_source, |
77
|
|
|
|
|
|
|
name => $self->friendly_name, |
78
|
|
|
|
|
|
|
comp_path => $self->comp_path, |
79
|
|
|
|
|
|
|
comp_class => $self->comp_class, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |