line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::Filters::Standard; |
2
|
|
|
|
|
|
|
$Mason::Filters::Standard::VERSION = '2.24'; |
3
|
19
|
|
|
19
|
|
17801
|
use Mason::DynamicFilter; |
|
19
|
|
|
|
|
55
|
|
|
19
|
|
|
|
|
793
|
|
4
|
19
|
|
|
19
|
|
146
|
use Mason::Util; |
|
19
|
|
|
|
|
30
|
|
|
19
|
|
|
|
|
876
|
|
5
|
19
|
|
|
19
|
|
94
|
use Mason::PluginRole; |
|
19
|
|
|
|
|
31
|
|
|
19
|
|
|
|
|
167
|
|
6
|
|
|
|
|
|
|
|
7
|
19
|
|
|
19
|
|
94009
|
method Capture ($outref) { |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1
|
|
8
|
1
|
|
|
1
|
|
2
|
sub { $$outref = $_[0]; return '' } |
|
1
|
|
|
|
|
3
|
|
9
|
1
|
|
|
|
|
11
|
} |
10
|
|
|
|
|
|
|
|
11
|
19
|
|
|
19
|
|
7023
|
method CompCall ($path, @params) { |
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
12
|
|
|
|
|
|
|
Mason::DynamicFilter->new( |
13
|
|
|
|
|
|
|
filter => sub { |
14
|
1
|
|
|
1
|
|
22
|
my $m = $self->m; |
15
|
1
|
|
|
|
|
8
|
return $m->scomp( $path, @params, yield => $_[0] ); |
16
|
|
|
|
|
|
|
} |
17
|
1
|
|
|
|
|
34
|
); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
19
|
|
|
19
|
|
6934
|
method NoBlankLines () { |
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
21
|
|
|
|
|
|
|
sub { |
22
|
1
|
|
|
1
|
|
3
|
my $text = $_[0]; |
23
|
1
|
|
|
|
|
8
|
$text =~ s/^\s*\n//mg; |
24
|
1
|
|
|
|
|
2
|
return $text; |
25
|
1
|
|
|
|
|
6
|
}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
19
|
|
|
19
|
|
6854
|
method Repeat ($times) { |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1
|
|
29
|
|
|
|
|
|
|
Mason::DynamicFilter->new( |
30
|
|
|
|
|
|
|
filter => sub { |
31
|
1
|
|
|
1
|
|
1
|
my $content = ''; |
32
|
1
|
|
|
|
|
4
|
for ( my $i = 0 ; $i < $times ; $i++ ) { |
33
|
3
|
|
|
|
|
5
|
$content .= $_[0]->(); |
34
|
|
|
|
|
|
|
} |
35
|
1
|
|
|
|
|
3
|
return $content; |
36
|
|
|
|
|
|
|
} |
37
|
1
|
|
|
|
|
31
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
19
|
|
|
19
|
|
7128
|
method Tee ($outref) { |
|
1
|
|
|
1
|
|
9
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
41
|
1
|
|
|
1
|
|
2
|
sub { $$outref = $_[0]; return $_[0] } |
|
1
|
|
|
|
|
2
|
|
42
|
1
|
|
|
|
|
7
|
} |
43
|
|
|
|
|
|
|
|
44
|
19
|
|
|
19
|
|
6186
|
method Trim () { |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
1
|
|
45
|
1
|
|
|
1
|
|
4
|
sub { Mason::Util::trim( $_[0] ) } |
46
|
1
|
|
|
|
|
9
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Mason::Filters::Standard - Standard filters |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
These filters are automatically composed into |
61
|
|
|
|
|
|
|
L<Mason::Component|Mason::Component>. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 FILTERS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item Capture ($ref) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Uses C<< $m->capture >> to capture the content in I<$ref> instead of outputting |
70
|
|
|
|
|
|
|
it. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
% $.Capture(\my $content) {{ |
73
|
|
|
|
|
|
|
<!-- this will end up in $content --> |
74
|
|
|
|
|
|
|
% }} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
... do something with $content |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item CompCall ($path, @args...) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Calls the component with I<path> and I<@args>, just as with C<< $m->scomp >>, |
81
|
|
|
|
|
|
|
with an additional coderef argument C<yield> that can be invoked to generate |
82
|
|
|
|
|
|
|
the content. Arguments passed to C<yield> can be accessed inside the content |
83
|
|
|
|
|
|
|
via C<@_>. This is the replacement for Mason 1's L<Components With |
84
|
|
|
|
|
|
|
Content|http://search.cpan.org/perldoc?HTML::Mason::Devel#Component_Calls_with_Content>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
In index.mc: |
87
|
|
|
|
|
|
|
% $.CompCall ('list_items.mi', items => \@items) {{ |
88
|
|
|
|
|
|
|
<li><% $_[0] %></li> |
89
|
|
|
|
|
|
|
% }} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
In list_items.mi: |
92
|
|
|
|
|
|
|
<%class> |
93
|
|
|
|
|
|
|
has 'items'; |
94
|
|
|
|
|
|
|
has 'yield'; |
95
|
|
|
|
|
|
|
</%class> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
% foreach my $item (@{$.items}) { |
98
|
|
|
|
|
|
|
<% $.yield->($item) %> |
99
|
|
|
|
|
|
|
% } |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item NoBlankLines |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Remove lines with only whitespace from content. This |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
% $.NoBlankLines {{ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
hello |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
world |
111
|
|
|
|
|
|
|
% }} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
yields |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
hello |
116
|
|
|
|
|
|
|
world |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item Repeat ($count) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Repeat the content block I<$count> times. Note that the block is re-executed |
121
|
|
|
|
|
|
|
each time, which may result in different content. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
<!-- Prints 1 to 5 --> |
124
|
|
|
|
|
|
|
% my $i = 1; |
125
|
|
|
|
|
|
|
% $.Repeat(5) {{ |
126
|
|
|
|
|
|
|
<% $i++ %><br> |
127
|
|
|
|
|
|
|
% }} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item Tee ($ref) |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Uses C<< $m->capture >> to capture the content in I<$ref>, and also output it. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
% $.Tee(\my $content) {{ |
134
|
|
|
|
|
|
|
<!-- this will end up in $content and also be output --> |
135
|
|
|
|
|
|
|
% }} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
... |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
<!-- output content again down here --> |
140
|
|
|
|
|
|
|
<% $content %> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item Trim |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Remove whitespace from the beginning and end of the content. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=back |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SEE ALSO |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L<Mason::Manual::Filters|Mason::Manual::Filters>, L<Mason|Mason> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 AUTHOR |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Jonathan Swartz <swartz@pobox.com> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Jonathan Swartz. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
161
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |