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