Text-FillIn
view release on metacpan or search on metacpan
$template = new Text::FillIn();
$template->path('.', '/etc/template_dir'); # Where to find templates
$template->get_file('my_template'); # Gets ./my_template or
# /etc/template_dir/my_template
=head1 DESCRIPTION
This module provides a class for doing fill-in templates. These templates may be used
as web pages with dynamic content, e-mail messages with fill-in fields, or whatever other
uses you might think of. B<Text::FillIn> provides handy methods for fetching files
from the disk, printing a template while interpreting it (also called streaming),
and nested fill-in sections (i.e. expressions like [[ $th[[$thing2]]ing1 ]] are legal).
Note that the version number here is 0.04 - that means that the interface may change
a bit. In fact, it's already changed some with respect to 0.02 (see the CHANGES file).
In particular, the $LEFT_DELIM, $RIGHT_DELIM, %HOOK, and @TEMPLATE_PATH variables are
gone, replaced by a default/instance variable system.
I might also change the default hooks or something. Please read the CHANGES file before upgrading
to find out whether I've changed anything you use.
Returns the interpreted contents of the template:
$interpreted_text = $template->interpret();
This, along with interpret_and_print, are the main point of this whole module.
=item * $template->interpret_and_print()
Interprets the [[ fill-in parts ]] of a template and prints the template,
streaming its output as much as possible. This means that if it encounters
an expression like "[[ stuff [[ more stuff]] ]]", it will fill in [[ more stuff ]],
then use the filled-in value to resolve the value of [[ stuff something ]],
and then print it out.
If it encounters an expression like "stuff1 [[thing1]] stuff2 [[thing2]]",
it will print stuff1, then the value of [[thing1]], then stuff2, then the
value of [[thing2]]. This is as streamed as possible if you want nested
brackets to resolve correctly.
=back
( run in 0.249 second using v1.01-cache-2.11-cpan-4d50c553e7e )