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.58'; |
7
|
33
|
|
|
33
|
|
191
|
use strict; |
|
33
|
|
|
|
|
62
|
|
|
33
|
|
|
|
|
798
|
|
8
|
33
|
|
|
33
|
|
150
|
use warnings; |
|
33
|
|
|
|
|
56
|
|
|
33
|
|
|
|
|
639
|
|
9
|
33
|
|
|
33
|
|
152
|
use File::Basename; |
|
33
|
|
|
|
|
60
|
|
|
33
|
|
|
|
|
1669
|
|
10
|
33
|
|
|
33
|
|
163
|
use File::Spec; |
|
33
|
|
|
|
|
61
|
|
|
33
|
|
|
|
|
784
|
|
11
|
33
|
|
|
33
|
|
153
|
use HTML::Mason::Exceptions( abbr => [qw(param_error error)] ); |
|
33
|
|
|
|
|
75
|
|
|
33
|
|
|
|
|
250
|
|
12
|
33
|
|
|
33
|
|
174
|
use Params::Validate qw(:all); |
|
33
|
|
|
|
|
68
|
|
|
33
|
|
|
|
|
5510
|
|
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
|
|
|
|
|
237
|
( read_only => [ qw( comp_id |
35
|
|
|
|
|
|
|
friendly_name |
36
|
|
|
|
|
|
|
last_modified |
37
|
|
|
|
|
|
|
comp_path |
38
|
|
|
|
|
|
|
comp_class |
39
|
|
|
|
|
|
|
extra |
40
|
|
|
|
|
|
|
) ], |
41
|
33
|
|
|
33
|
|
224
|
); |
|
33
|
|
|
|
|
63
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my %defaults = ( comp_class => 'HTML::Mason::Component' ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new |
46
|
|
|
|
|
|
|
{ |
47
|
1145
|
|
|
1145
|
1
|
2632
|
my $class = shift; |
48
|
|
|
|
|
|
|
|
49
|
1145
|
|
|
|
|
11013
|
return bless { %defaults, @_ }, $class |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub comp_source_ref |
53
|
|
|
|
|
|
|
{ |
54
|
548
|
|
|
548
|
0
|
1141
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
548
|
|
|
|
|
994
|
my $source = eval { $self->{source_callback}->() }; |
|
548
|
|
|
|
|
2012
|
|
57
|
|
|
|
|
|
|
|
58
|
548
|
|
|
|
|
2615
|
rethrow_exception $@; |
59
|
|
|
|
|
|
|
|
60
|
547
|
50
|
|
|
|
1452
|
unless ( defined $source ) |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
|
|
0
|
error "source callback returned no source for $self->{friendly_name} component"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
547
|
100
|
|
|
|
1599
|
my $sourceref = ref($source) ? $source : \$source; |
66
|
547
|
|
|
|
|
1970
|
return $sourceref; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
30
|
|
|
30
|
1
|
117
|
sub comp_source { ${shift()->comp_source_ref} } |
|
30
|
|
|
|
|
84
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub object_code |
72
|
|
|
|
|
|
|
{ |
73
|
29
|
|
|
29
|
1
|
54
|
my $self = shift; |
74
|
29
|
|
|
|
|
604
|
my %p = validate( @_, { compiler => { isa => 'HTML::Mason::Compiler' } } ); |
75
|
|
|
|
|
|
|
|
76
|
29
|
|
|
|
|
193
|
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__ |