line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markapl::Helpers; |
2
|
2
|
|
|
2
|
|
2322
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
69
|
|
3
|
2
|
|
|
2
|
|
10
|
use Markapl; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
2617
|
use Exporter::Lite; |
|
2
|
|
|
|
|
1437
|
|
|
2
|
|
|
|
|
9
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
7
|
|
|
|
|
|
|
our @EXPORT = qw(THs TDs ths tds heads cells linklist); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub linklist { |
10
|
1
|
|
|
1
|
1
|
5
|
my @link = @_; |
11
|
2
|
|
|
2
|
|
159
|
ul { |
12
|
1
|
|
|
1
|
|
10
|
while(@link) { |
13
|
2
|
|
|
|
|
3
|
my $label = shift @link; |
14
|
2
|
|
|
|
|
3
|
my $url = shift @link; |
15
|
2
|
|
|
2
|
|
112
|
li { |
16
|
2
|
|
|
2
|
|
114
|
a(href => $url) { $label }; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
6
|
|
17
|
2
|
|
|
|
|
11
|
} |
18
|
|
|
|
|
|
|
} |
19
|
1
|
|
|
|
|
8
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub heads { |
23
|
4
|
|
|
4
|
1
|
30
|
my @heads = @_; |
24
|
2
|
|
|
2
|
|
115
|
row { for (@heads) { th { $_ } } } |
|
2
|
|
|
2
|
|
121
|
|
|
4
|
|
|
4
|
|
33
|
|
|
4
|
|
|
|
|
9
|
|
|
16
|
|
|
|
|
78
|
|
|
16
|
|
|
|
|
43
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub cells { |
28
|
4
|
|
|
4
|
1
|
112
|
my @cells = @_; |
29
|
2
|
|
|
2
|
|
123
|
row { for (@cells) { cell { $_ } } } |
|
2
|
|
|
2
|
|
117
|
|
|
4
|
|
|
4
|
|
23
|
|
|
4
|
|
|
|
|
7
|
|
|
16
|
|
|
|
|
70
|
|
|
16
|
|
|
|
|
38
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
*THs = \&heads; |
33
|
|
|
|
|
|
|
*ths = \&heads; |
34
|
|
|
|
|
|
|
*TDs = \&cells; |
35
|
|
|
|
|
|
|
*tds = \&cells; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Markapl::Helpers - Practical helper methods |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This module exports several useful functions that are meant to be used |
46
|
|
|
|
|
|
|
inside templates. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 FUNCTIONS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=over 4 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item linklist($label1 => $url1, $label2 => $url2, ...) |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Take pairs of labels and urls, return a structure like this: |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$label1 |
58
|
|
|
|
|
|
|
$label2 |
59
|
|
|
|
|
|
|
... |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item cells($item1, $item2, ...) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Wrap C<< | | >> tag around each item in the argument list.
65
|
|
|
|
|
|
|
Useful when showing tabular data. For example: |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
table { |
68
|
|
|
|
|
|
|
while(my @data = $dbh->fetchrow_array) { |
69
|
|
|
|
|
|
|
cells(@data); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item heads($item1, $item2, ...) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Similar to C, but output seris of C<< | >> tag instead. |
76
|
|
|
|
|
|
|
For example: |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
table { |
79
|
|
|
|
|
|
|
heads( qw(Name Age Gender Height Weight) ); |
80
|
|
|
|
|
|
|
while(my @data = $dbh->fetchrow_array) { |
81
|
|
|
|
|
|
|
cells(@data); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Kang-min Liu C<< >> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Copyright (c) 2008, Kang-min Liu C<< >>. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This is free software, licensed under: |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The MIT (X11) License |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
102
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
103
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
104
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
105
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
106
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
107
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
108
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
109
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
112
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
113
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
114
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
115
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
116
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
117
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
118
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
119
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
120
|
|
|
|
|
|
|
SUCH DAMAGES. |