1CGI::Pretty(3pm) Perl Programmers Reference Guide CGI::Pretty(3pm)
2
3
4
6 CGI::Pretty - module to produce nicely formatted HTML code
7
9 use CGI::Pretty qw( :html3 );
10
11 # Print a table with a single data element
12 print table( TR( td( "foo" ) ) );
13
15 CGI::Pretty is a module that derives from CGI. It's sole function is
16 to allow users of CGI to output nicely formatted HTML code.
17
18 When using the CGI module, the following code:
19 print table( TR( td( "foo" ) ) );
20
21 produces the following output:
22 <TABLE><TR><TD>foo</TD></TR></TABLE>
23
24 If a user were to create a table consisting of many rows and many col‐
25 umns, the resultant HTML code would be quite difficult to read since it
26 has no carriage returns or indentation.
27
28 CGI::Pretty fixes this problem. What it does is add a carriage return
29 and indentation to the HTML code so that one can easily read it.
30
31 print table( TR( td( "foo" ) ) );
32
33 now produces the following output:
34 <TABLE>
35 <TR>
36 <TD>
37 foo
38 </TD>
39 </TR>
40 </TABLE>
41
42 Tags that won't be formatted
43
44 The <A> and <PRE> tags are not formatted. If these tags were format‐
45 ted, the user would see the extra indentation on the web browser caus‐
46 ing the page to look different than what would be expected. If you
47 wish to add more tags to the list of tags that are not to be touched,
48 push them onto the @AS_IS array:
49
50 push @CGI::Pretty::AS_IS,qw(CODE XMP);
51
52 Customizing the Indenting
53
54 If you wish to have your own personal style of indenting, you can
55 change the $INDENT variable:
56
57 $CGI::Pretty::INDENT = "\t\t";
58
59 would cause the indents to be two tabs.
60
61 Similarly, if you wish to have more space between lines, you may change
62 the $LINEBREAK variable:
63
64 $CGI::Pretty::LINEBREAK = "\n\n";
65
66 would create two carriage returns between lines.
67
68 If you decide you want to use the regular CGI indenting, you can easily
69 do the following:
70
71 $CGI::Pretty::INDENT = $CGI::Pretty::LINEBREAK = "";
72
74 This section intentionally left blank.
75
77 Brian Paulsen <Brian@ThePaulsens.com>, with minor modifications by Lin‐
78 coln Stein <lstein@cshl.org> for incorporation into the CGI.pm distri‐
79 bution.
80
81 Copyright 1999, Brian Paulsen. All rights reserved.
82
83 This library is free software; you can redistribute it and/or modify it
84 under the same terms as Perl itself.
85
86 Bug reports and comments to Brian@ThePaulsens.com. You can also write
87 to lstein@cshl.org, but this code looks pretty hairy to me and I'm not
88 sure I understand it!
89
91 CGI
92
93
94
95perl v5.8.8 2001-09-21 CGI::Pretty(3pm)