/[pxelator]/lib/PXElator/html.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/PXElator/html.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 187 - (show annotations)
Sun Aug 9 21:59:17 2009 UTC (14 years, 8 months ago) by dpavlin
File size: 1167 byte(s)
fix empty strings highlight

1 package html;
2
3 use Data::Dump qw/dump/;
4
5 sub table {
6 my $cols = shift;
7 my $th;
8
9 if ( $cols < 0 ) {
10 $cols = abs($cols);
11 $th .= qq|<th>| . shift(@_) . qq|</td>| foreach ( 1 .. $cols );
12 $th .= qq|</tr>\n<tr>|;
13 }
14
15 my @td = map { "<td>$_</td>" } @_;
16 my $html = qq{<table>\n<tr>$th};
17 foreach ( 0 .. $#td ) {
18 $html .= $td[$_];
19 $html .= qq{</tr>\n<tr>} if ( $_ + 1 ) % $cols == 0;
20 }
21 $html .= qq{</tr>\n</table>};
22 }
23
24 sub tabs {
25 return unless @_;
26 my $html = qq{<table border=1>\n<tr>};
27 foreach my $row ( @_ ) {
28 $row =~ s{\t}{</td><td>}g;
29 $html .= qq|<tr><td>$row</td><tr>\n|;
30 }
31 $html .= qq|</table>|;
32 return $html;
33 }
34
35
36 sub tt {
37 qq|<tt>| . join(' ', @_) . qq|</tt>|;
38 }
39
40 sub select {
41 my $name = shift;
42 my $selected_option = shift;
43 return join("\n"
44 , qq|<select type=select name=$name>|
45 , join("\n", map { my $selected = $_ eq $selected_option ? 'selected' : ''; qq|<option name=$_ $selected>$_</option>| } @_ )
46 , qq|</select>|
47 , qq|</form>|
48 );
49 }
50
51 sub pre_dump {
52 my $data = shift;
53 my $dump = dump( $data );
54 $dump =~ s{"([^"]+)"(\s*=>)}{$1 $2}gs;
55 $dump =~ s{"([^"]*)"}{"<b>$1</b>"}gs;
56 qq|<pre>$dump</pre>|;
57 }
58
59 warn "loaded";
60
61 1;

  ViewVC Help
Powered by ViewVC 1.1.26