Text::FastTemplate v0.94				Robert Lehr
October 17, 2001					bozzio@the-lehrs.com

################################################################################

Text::FastTemplate is yet another template module written in Perl.  So why
use this module instead of one of the other template modules?  Well,it's...

  + ultra simple, both the template syntax and the API.
  + fast, by compiling templates into subs, we let perl do the real work.
  + lean, a single file with no external dependencies.
  + completely separates the presentation from the application logic.
  + comprehensive, does substitutions, includes, conditions and loops.
  + a class, i.e. it's object-oriented.

SIMPLE:

This template uses a C-preprocessor style syntax, which means that it is
line-oriented.  Anybody that is familiar with the C-preprocessor knows that its
syntax is brain-dead simple.  Unlike the C-preprocessor, this template provides
syntax for a loop around a text block that you might want to repeat.

FAST:

Like some other template modules, this template module converts the template
text into a subroutine and passes it to Perl's compiler.  This compiled
subroutine is then cached to perform the actual template processing and output.

LEAN:

Very little code comprises this module.  There are also no typeglobs, which
means no memory leaks.  One of the reasons this was originally written was
because a memory leak was discovered in one of the more popular template
modules, one which happened to be my favourite, when used in Apache/mod_perl.

OBJECT-ORIENTED:

Since it is a class, it is easily extensible.  One of my favourite applications
of this module is to derive a Page class from it.  The Page class overrides the
output() method with its own output() method that passes some common macroes,
such as a DATE or USER_ID string, with the original macroes to the parent
class output().

################################################################################

This module is most useful in Perl programs that use the same template several
times during the lifetime of its execution, particularly a persistent process
such as an Apache/mod_perl server (surprise!)  or some other server/daemon.

Why another template module?  I can describe it best by explaining why it was
ever written.  We didn't want to write another template module.  We set our
criteria and looked for a module that would work for our project.  We tried a
couple of the popular modules but abandoned them.  Why?

HTML::Template ?
	pros:	simple syntax, complete isolation of HTML from perl code
	cons:	memory leak, slow

HTML::Mason ?
	pros:	nice component structure, fast
	cons:	too easy to mix perl and HTML,
		too complex for lame HTML coder

Text::Template ?
	pros:	could make our own template syntax
	cons:	too much overhead, too complex, meant too slow

In the end, we wanted a template that was simple, fast and completely separated
the text template from the perl code.  We got it by using:
  + C-preprocessor line-oriented syntax (SIMPLICITY)
  + converting templates into perl subroutines and
    compiling and caching it (SPEED)

Our design gave us two additional benefits that we didn't anticipate:
  + component-type flexibility, like Mason.
  + general text-template capability, i.e. it is not restricted to HTML.

HTML::Template was my favourite web template module until I discovered the
memory leak that is caused by the typeglobs during its output() method.  That
was just the clincher.  The HTML-style syntax made it a hard-sell to the lead
engineer for the project on which I discovered the memory-leak.  Not to mention,
I was trying to replace a template system that only did simple substitution;
repetitive HTML code, such as table rows, was generated by HTML embedded in the
application code.  We had the worst of both worlds.  So what's the problem?  It
should have been a shoe-in, right?  That should have been the case.  But that
pre-existing, lame template system was fast, much faster than HTML::Template.
So speed became a constraint as I searched for a replacement template module; I
couldn't make the application slower than it already was.  It had to be simple
and fast.  So, Text::FastTemplate is really HTML::Template rewritten to be
_much_ faster, with a simpler macro syntax, without a memory-leak and useful for
more than just web pages.

################################################################################

I certainly would appreciate any feedback from people that use it, including
complaints, suggestions, patches or anything.  Even people that don't use it
are welcome to send comments.

Thanks for using Text::FastTemplate and for your feedback.

Cordially,
Robert Lehr
bozzio@the-lehrs.com

################################################################################

Legal information:

    Copyright (c) 2001 Robert Lehr. All rights reserved.  This program is free
    software; you can redistribute it and/or modify it under the same terms as
    Perl itself.

    Caveat emptor.  Use this module at your own risk.  I will accept no
    responsibility any loss of any kind that is the direct or indirect result
    of the use of this module.

################################################################################

$Rev$