#============================================================= -*-perl-*- # # Template::Library::HTML # # DESCRIPTION # The HTML library provides a number of basic templates for use in # building HTML pages. # # AUTHOR # Andy Wardley # # 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.69 # #======================================================================== #------------------------------------------------------------------------ # 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 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 Cinstdir()> 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. . . .
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 EhtmlE to the opening EbodyE. [% 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 %] [% END %] [% INCLUDE html/header title = 'This is a Test' bgcol = '#ffffff' %] =item footer The 'footer' element generates the terminating E/bodyE and E/htmlE 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 = '' %] ...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' %] Hello World [% 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 %] Hello World [% 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 %] Foo Bar [% 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 Eabw@andywardley.comE L =head1 VERSION 2.69, distributed as part of the Template Toolkit version 2.13, released on 30 January 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 =cut # Local Variables: # mode: perl # perl-indent-level: 4 # indent-tabs-mode: nil # End: # # vim: expandtab shiftwidth=4: