NAME

HTML::Template::Preload - Preload HTML::Template templates into cache.

SYNOPSIS

Preload HTML::Template templates into cache:

use HTML::Template::Preload qw(-path => '/some/path', cache => 1);

DESCRIPTION

HTML::Template supports the concept of a 'cache' which is use to hold pre-parsed templates. At the same time, HTML::Template supports a number of different types of caching mechanisms.

In a Apache/ModPerl environment, there may be a small but significant performance benefit having Apache pre-load the templates, so as to avoid needing the Apache-child-instances parse the templates, as they will have inherited the parent instance cache. To make this work, you would call this module from your startup.pl in Apache/mod_perl.

Thus this module pre-parses all the templates, then places them into the selected cache.

USAGE

You can use this module in one of two ways, either: a) In your 'use' statement, provide it with your HTML::Template cache info, as in:

  use HTML::Template::Preload qw(
    -path => '/some/path',
    -path => 'some/other/path',
    cache => 1,
  );

b) Or inside your program code:

  use HTML::Template::Preload;
  ...
  my %ht_options;
  $ht_options{path} = \@search_paths;
  $ht_options{global_vars} = 1;
  $ht_options{strict} = 0;
  $ht_options{cache} = 1;
  ...
  HTML::Template::Preload->preload(%ht_options);

HTML::Template::Preload takes a hash of named arguments:

-extension
        The filename extension you use for all of your
        templates.  Defaults to: .tmpl

-file   Name a specific file or files to cache.  Takes
        a scalar or an array of filenames.  This uses
        the search path to find the template files; as
        implemented by HTML::Template.

-path   Name a specific search path or paths.  Takes a
        scalar or an array of paths.  This will usually
        be the same list as would be passed to the 'path'
        argument to HTML::Template.

-function
        sub's to functions that need to be registered
        for HTML::Template::Expr.

All other arguments (that dont begin with a '-') are passed to the HTML::Template caching-instance.

Note that you dont need to specify the "-xxx" variation of these arguments -> you can simply use the same hash-options as given to HTML::Template. The point of these extra options is to allow for explicitly caching a specific template.

AUTHOR

Mathew Robertson (mathew@users.sf.net)

LICENSE

This module is released under the same license as the license the HTML::Template is released under.