1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
|
#============================================================= -*-perl-*-
#
# Template::Library::HTML
#
# DESCRIPTION
# The HTML library provides a number of basic templates for use in
# building HTML pages.
#
# AUTHOR
# Andy Wardley <abw@andywardley.com>
#
# COPYRIGHT
# Copyright (C) 1996-2001 Andy Wardley. All Rights Reserved.
# Copyright (C) 1998-2001 Canon Research Centre Europe Ltd.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# REVISION
# 2.70
#
#========================================================================
#------------------------------------------------------------------------
# IMPORTANT NOTE
# This documentation is generated automatically from source
# templates. Any changes you make here may be lost.
#
# The 'docsrc' documentation source bundle is available for download
# from http://www.template-toolkit.org/docs.html and contains all
# the source templates, XML files, scripts, etc., from which the
# documentation for the Template Toolkit is built.
#------------------------------------------------------------------------
=head1 NAME
Template::Library::HTML - Template library for building basic HTML pages
=head1 DESCRIPTION
B<NOTE:> This documentation is incomplete and may be incorrect
in places.
The 'html' template library is distributed as part of the Template
Toolkit. It can be found in the 'templates' sub-directory of the
installation directory.
use Template;
my $tt2 = Template->new({
INCLUDE_PATH => '/usr/local/tt2/templates',
});
For a portable way to determine the installation 'templates' directory,
you can use the C<Template::Config-E<gt>instdir()> class method.
use Template;
my $tt2 = Template->new({
INCLUDE_PATH => Template::Config->instdir('templates'),
});
You should now be able to access the html library as, for example:
[% INCLUDE html/header %]
Note that some of the more basic elements don't give you much more
than the raw HTML tags. In many cases you might be well advised to
stick to regular HTML rather than complicating matters by the use
of template elements.
e.g.
<table>
. . .
</table>
vs
[% WRAPPER html/table %]
. . .
[% END %]
However, the use of template elements to generate the underlying HTML
does have some important benefits, particularly as the constructs start
to get more complicated and more magical.
See the example in the 'examples' sub-directory of the distribution
directory for further examples and enlightenment on using this library.
=head2 Headers, Footers and Pages
=over 4
=item header
The 'header' element generates the regular header required as the
pre-amble for an HTML document. That is, everything from the initial
E<lt>htmlE<gt> to the opening E<lt>bodyE<gt>.
[% INCLUDE html/header
title = 'This is a Test'
bgcol = '#ffffff'
%]
Additional header items can be provided by explicitly setting the 'headers'
variable, e.g.
[% headers = BLOCK %]
<META name="description" content="Template Toolkit">
<META name="REVISIT-AFTER" content="14 days">
<META name="keywords" content="Templates, Web, ...etc...">
[% END %]
[% INCLUDE html/header
title = 'This is a Test'
bgcol = '#ffffff'
%]
=item footer
The 'footer' element generates the terminating E<lt>/bodyE<gt> and
E<lt>/htmlE<gt> element to balance the header.
[% PROCESS html/header %]
...page content here...
[% PROCESS html/footer %]
=item page
The 'page' element combines the 'html/header' and 'html/footer' elements.
[% WRAPPER html/page %]
...page content here...
[% END %]
Page content should be defined in the 'content' variable (e.g. via WRAPPER).
Additional HTML headers should be defined in the 'headers' variable.
[% WRAPPER html/page
headers = '<META name="keywords" content="foo, bar, ...">'
%]
...page content here...
[% END %]
=back
=head2 Tables, Bars and Boxes
=over 4
=item table
A basic element for creating HTML tables.
[% WRAPPER html/table pad=10 space=4 col='#404040' %]
<tr>
<td>Hello</td> <td>World</td>
</tr>
[% END %]
The following variables may be defined:
=over 4
=item border
Set the border width (default: 0)
=item col
Set the background colour (default: none).
=item width
Set a fixed table width.
=item pad
Set the cellpadding.
=item space
Set the cellspacing.
=item content
Content for the box. Supplied automatically if used via WRAPPER.
=back
=item row
A basic element for creating HTML table rows.
[% WRAPPER html/table %]
[% WRAPPER html/row %]
<td>Hello</td> <td>World</td>
[% END %]
[% END %]
The following variables may be defined:
=over 4
=item col
Set the background colour (default: none).
=item valign
Set the vertical alignment.
=item rowspan
Specify the number of rows to span.
=item content
Content for the box. Supplied automatically if used via WRAPPER.
=back
=item cell
A basic element for creating HTML table cells.
[% WRAPPER html/table %]
[% WRAPPER html/row %]
[% INCLUDE html/cell
FOREACH content = ['Hello', 'World'] %]
[% END %]
[% END %]
The following variables may be defined:
=over 4
=item col
Set the background colour (default: none).
=item align
Set the horizontal alignment.
=item colspan
Specify the number of columns to span.
=item content
Content for the cell. Supplied automatically if used via WRAPPER.
=back
=item bar
The bar element is a wrapping of html/table + html/row.
[% WRAPPER html/bar %]
<td>Foo</td> <td>Bar</td>
[% END %]
=item box
The box element is a wrapping of html/table + html/row + html/cell
[% WRAPPER html/box %]
Hello World!
[% END %]
=back
=head1 AUTHOR
Andy Wardley E<lt>abw@andywardley.comE<gt>
L<http://www.andywardley.com/|http://www.andywardley.com/>
=head1 VERSION
2.70, distributed as part of the
Template Toolkit version 2.14, released on 04 October 2004.
=head1 COPYRIGHT
Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=head1 SEE ALSO
L<Template::Library::Splash|Template::Library::Splash>
=cut
# Local Variables:
# mode: perl
# perl-indent-level: 4
# indent-tabs-mode: nil
# End:
#
# vim: expandtab shiftwidth=4:
|