line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
1286
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
76
|
|
2
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
134
|
|
3
|
|
|
|
|
|
|
package HTML::MasonX::Free::Component; |
4
|
|
|
|
|
|
|
# ABSTRACT: a component with a "main" method, not just a bunch of text |
5
|
|
|
|
|
|
|
$HTML::MasonX::Free::Component::VERSION = '0.006'; |
6
|
3
|
|
|
3
|
|
11
|
use parent 'HTML::Mason::Component::FileBased'; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
14
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 OVERVIEW |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod In concept, a Mason component is broken down into special blocks (like once, |
11
|
|
|
|
|
|
|
#pod shared, init), methods, and subcomponents. When you render a Mason component, |
12
|
|
|
|
|
|
|
#pod using it as a template, you aren't calling one of its methods or blocks. |
13
|
|
|
|
|
|
|
#pod Instead, all the stray code and text that was found I<outside> all of those is |
14
|
|
|
|
|
|
|
#pod concatenated together and run. |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod This is sort of a mess. |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod If you use HTML::MasonX::Free::Component as your component class instead, |
19
|
|
|
|
|
|
|
#pod rendering the component will call its C<main> method instead of all that other |
20
|
|
|
|
|
|
|
#pod junk. This component class extends HTML::Mason::Component::FileBased. If this |
21
|
|
|
|
|
|
|
#pod is a problem because of your esoteric Mason configuration, don't panic. Just |
22
|
|
|
|
|
|
|
#pod read the source. Seriously, it's tiny. |
23
|
|
|
|
|
|
|
#pod |
24
|
|
|
|
|
|
|
#pod This component class is meant to work well with |
25
|
|
|
|
|
|
|
#pod L<HTML::MasonX::Free::Compiler>, which will let you throw a syntax exception if |
26
|
|
|
|
|
|
|
#pod there's any significant content outside of blocks, and which can apply |
27
|
|
|
|
|
|
|
#pod C<default_method_to_call> to calls found when compiling. |
28
|
|
|
|
|
|
|
#pod |
29
|
|
|
|
|
|
|
#pod You can pass a C<default_method_to_call> argument to the constructor for this |
30
|
|
|
|
|
|
|
#pod class, but it's not all that easy to get where you need it, so maybe you should |
31
|
|
|
|
|
|
|
#pod stick with the default: C<main> |
32
|
|
|
|
|
|
|
#pod |
33
|
|
|
|
|
|
|
#pod =cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
23
|
|
|
23
|
0
|
54
|
my ($class, %arg) = @_; |
37
|
23
|
|
50
|
|
|
91
|
my $default_method_to_call = delete $arg{default_method_to_call} || 'main'; |
38
|
23
|
|
|
|
|
74
|
my $self = $class->SUPER::new(%arg); |
39
|
23
|
|
|
|
|
531
|
$self->{default_method_to_call} = $default_method_to_call; |
40
|
23
|
|
|
|
|
299
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub run { |
44
|
23
|
|
|
23
|
0
|
670
|
my $self = shift; |
45
|
23
|
|
|
|
|
23
|
$self->{mfu_count}++; |
46
|
23
|
|
|
|
|
70
|
$self->call_method($self->{default_method_to_call} => @_); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding UTF-8 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
HTML::MasonX::Free::Component - a component with a "main" method, not just a bunch of text |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
version 0.006 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 OVERVIEW |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
In concept, a Mason component is broken down into special blocks (like once, |
68
|
|
|
|
|
|
|
shared, init), methods, and subcomponents. When you render a Mason component, |
69
|
|
|
|
|
|
|
using it as a template, you aren't calling one of its methods or blocks. |
70
|
|
|
|
|
|
|
Instead, all the stray code and text that was found I<outside> all of those is |
71
|
|
|
|
|
|
|
concatenated together and run. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This is sort of a mess. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
If you use HTML::MasonX::Free::Component as your component class instead, |
76
|
|
|
|
|
|
|
rendering the component will call its C<main> method instead of all that other |
77
|
|
|
|
|
|
|
junk. This component class extends HTML::Mason::Component::FileBased. If this |
78
|
|
|
|
|
|
|
is a problem because of your esoteric Mason configuration, don't panic. Just |
79
|
|
|
|
|
|
|
read the source. Seriously, it's tiny. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This component class is meant to work well with |
82
|
|
|
|
|
|
|
L<HTML::MasonX::Free::Compiler>, which will let you throw a syntax exception if |
83
|
|
|
|
|
|
|
there's any significant content outside of blocks, and which can apply |
84
|
|
|
|
|
|
|
C<default_method_to_call> to calls found when compiling. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
You can pass a C<default_method_to_call> argument to the constructor for this |
87
|
|
|
|
|
|
|
class, but it's not all that easy to get where you need it, so maybe you should |
88
|
|
|
|
|
|
|
stick with the default: C<main> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Ricardo Signes <rjbs@cpan.org> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Ricardo Signes. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
99
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |