| 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.60'; |
|
7
|
33
|
|
|
33
|
|
237
|
use strict; |
|
|
33
|
|
|
|
|
72
|
|
|
|
33
|
|
|
|
|
921
|
|
|
8
|
33
|
|
|
33
|
|
161
|
use warnings; |
|
|
33
|
|
|
|
|
60
|
|
|
|
33
|
|
|
|
|
774
|
|
|
9
|
33
|
|
|
33
|
|
186
|
use File::Basename; |
|
|
33
|
|
|
|
|
68
|
|
|
|
33
|
|
|
|
|
2156
|
|
|
10
|
33
|
|
|
33
|
|
208
|
use File::Spec; |
|
|
33
|
|
|
|
|
76
|
|
|
|
33
|
|
|
|
|
1038
|
|
|
11
|
33
|
|
|
33
|
|
216
|
use HTML::Mason::Exceptions( abbr => [qw(param_error error)] ); |
|
|
33
|
|
|
|
|
105
|
|
|
|
33
|
|
|
|
|
316
|
|
|
12
|
33
|
|
|
33
|
|
247
|
use Params::Validate qw(:all); |
|
|
33
|
|
|
|
|
77
|
|
|
|
33
|
|
|
|
|
7164
|
|
|
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
|
|
|
|
|
358
|
( read_only => [ qw( comp_id |
|
35
|
|
|
|
|
|
|
friendly_name |
|
36
|
|
|
|
|
|
|
last_modified |
|
37
|
|
|
|
|
|
|
comp_path |
|
38
|
|
|
|
|
|
|
comp_class |
|
39
|
|
|
|
|
|
|
extra |
|
40
|
|
|
|
|
|
|
) ], |
|
41
|
33
|
|
|
33
|
|
279
|
); |
|
|
33
|
|
|
|
|
68
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my %defaults = ( comp_class => 'HTML::Mason::Component' ); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
1145
|
|
|
1145
|
1
|
2500
|
my $class = shift; |
|
48
|
|
|
|
|
|
|
|
|
49
|
1145
|
|
|
|
|
11108
|
return bless { %defaults, @_ }, $class |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub comp_source_ref |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
548
|
|
|
548
|
0
|
1243
|
my $self = shift; |
|
55
|
|
|
|
|
|
|
|
|
56
|
548
|
|
|
|
|
1093
|
my $source = eval { $self->{source_callback}->() }; |
|
|
548
|
|
|
|
|
2136
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
548
|
|
|
|
|
2785
|
rethrow_exception $@; |
|
59
|
|
|
|
|
|
|
|
|
60
|
547
|
50
|
|
|
|
1477
|
unless ( defined $source ) |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
0
|
|
|
|
|
0
|
error "source callback returned no source for $self->{friendly_name} component"; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
547
|
100
|
|
|
|
1509
|
my $sourceref = ref($source) ? $source : \$source; |
|
66
|
547
|
|
|
|
|
2244
|
return $sourceref; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
30
|
|
|
30
|
1
|
150
|
sub comp_source { ${shift()->comp_source_ref} } |
|
|
30
|
|
|
|
|
80
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub object_code |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
29
|
|
|
29
|
1
|
64
|
my $self = shift; |
|
74
|
29
|
|
|
|
|
700
|
my %p = validate( @_, { compiler => { isa => 'HTML::Mason::Compiler' } } ); |
|
75
|
|
|
|
|
|
|
|
|
76
|
29
|
|
|
|
|
205
|
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__ |