Text::FastTemplate v0.93 July 2, 2001 ################################################################################ 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. + it's fast. + it's lean. + it completely separates the presentation from the application logic. + it's a class. SIMPLE: This template uses a C-preprocessor style syntax, which means that it is line-oriented. Unlike the C-preprocessor, this template provides syntax for a loop around a block text 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 for successive uses. LEAN: There is very little code to this module. And there are 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 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 really only useful in Perl programs that use the same template several times during the lifetime of its execution such as Apache/mod_perl (surprise!) or some other server/daemon. Why another template module? I can describe it best by explaining why it was ever written template module. 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. Please note that I respect the templates that we evaluated. We simply had a set of requirements that none of them fulfilled completely. ################################################################################ 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. ################################################################################