package HTML::Template::HTX; $VERSION = '0.07'; # FOR PERL VERSIONS PRIOR TO 5.6 # # The next two lines should be disabled for Perl versions prior to 5.6. As # far as I know there is no (simple) way to do this automatically at compile # time, so you will have to do it yourself. require 5.006; use utf8; =head1 NAME HTML::Template::HTX - Handle HTML Extension template (F<.htx>) files =head1 SYNOPSIS use HTML::Template::HTX; $htx = HTML::Template::HTX->new('template.htx') or die "Oops!"; $htx->param('counter' => 0); $htx->print_header(1); foreach(qw(I used to care but Things Have Changed)) { $htx->param( 'counter' => $htx->param('counter')+1, 'Name' => $_, ); $htx->print_detail; } $htx->print_footer; $htx->close; =head2 template.htx Sample results

Sample results:

<%begindetail%> <%counter%>. <%Name%>
<%enddetail%> =head1 ABSTRACT Reads and outputs HTML Extension template (F<.htx>) files, which enable you to seperate your Perl code from HTML code. The F<.htx> file format was originally used by Microsoft's Index Server and their Internet Database Connector, but may be useful for any server side program that outputs HTML (or even some other ASCII file format), and especially for scripts generating sequential data, such as search engines. Note that this module and its template format are not directly related nor compatible with the popular HTML::Template module. =cut use strict; #use warnings; # Enable warnings only during development use FileHandle; use HTML::Entities qw(encode_entities); use URI::Escape qw(uri_escape); =head1 DESCRIPTION To use a F<.htx> template file in your Perl script, basically follow these steps: =over 4 =item 1 Create a L HTML::Template::HTX object. =item 2 Optionally define some L, and output the L of the template. =item 3 Optionally change or define some L, and output the L. This step is optionally repeated a number of times, depending on the data you're processing. =item 4 Optionally change or define some L, and output the L of the template. =item 5 L the template file, or destroy the HTML::Template::HTX object. =back If you don't have any repeated data, then you can skip steps 2 and 3, and just use C to output the whole template file at once. If you have multiple sets of repeated data, then you should probably follow a slightly altered schema (see the C method). =head2 Basic methods =over 4 =item C<$htx = HTML::Template::HTX-Enew($template,> [C<$output>]C<,> [C<-utf8>]C<,> [I]C<)> =item C<$htx = HTML::Template::HTX-Enew(template =E $template,> [C $output>]C<,> [C<-utf8>]C<,> [I]C<)> Opens the specified F<.htx> template file. If an open file handle is specified instead of a file name, then the template is read from this file handle. If a scalar reference is specified, then the contents of the scalar will be used as the template. If no output file is specified, then the STDOUT is used for output. If an open file handle is specified, then this file handle is used for output. If a scalar reference is specified instead of an output file, then all output will be B to the specified scalar. By default UTF-8 coding will be disabled, but you can specify C<-utf8> to enable it. For more on UTF-8 coding and this module see the C method. When any common parameters are specified, certain frequently used parameters are automatically defined and maintained. For more information see the C method. When using the named parameters interface, you can also use C $template> instead of C