Long ago, in a galaxy far, far, away....

Seriously, I encountered class.FastTemplate.php while doing a consulting job in in the last millenium. It had a lot of nifty features I liked, but there were some rough edges with some incomplete features, the biggest of which was it's recursive template feature. Since LISP was the first programming language I learned, I'm kind of fond of recursion, so I started writing my own replacement with class.FastTemplate.php compatibility as a major goal. In the process, I also took advantage of some things which may not have existed when class.FastTemplate.php was written, namely the ability to return and pass around variable by reference. That trick made class.rFastTemplate.php really fast compared to the original. Okay, at least for my cases and I've had others tell me the same thing. I don't have any benchmarks---you'll have to do your own.

One of the things I like about the template approach in general is the ability to separate code from content. And, in fact, I like to separate things into code, layout, and content. That's sort of the point of the template, it provides the layout, the content lives elsewhere, and there is some code that puts its all together. My original website quickly morphed into something that used my new class.rFastTemplate.php exclusively to maintain consistency throughout. Eventually, the world passed me by and I found I really wanted a content management system to make my life easier. Ah, but using a CMS comes with a price: I get what the authors think are cool features which for me meant reduced flexibility in a number of areas. Oh well, life is about trade-offs.

Even then, I decide that I liked my own templating system enough that I wrote a new theme for Drupal called (tada!) astrofoto. The obvious things it includes are all the CSS changes to get the lovely color scheme you are currently viewing. But I didn't like the mixture of code and format information in the default Drupal themes, so I split them apart using (you're way ahead of me, I see) class.rFastTemplate.php.

My use of class.rFastTemplate.php is not really a new theme engine in Drupal, it works in conjunction with the default theme engine in a sort of hybrid mode. XTemplate loads my PHP fragments which use class.rFastTemplate. But for me, the big win is that my layout is easy to read and I don't have to touch the code to change it. And much of it can be modified via CSS (like the default Drupal theme on which is was based).

Your old templates should work just fine. If they don't, please let me know. Comptability was one of the goals; to have a real drop-in replacement for class.FastTemplate. I like the nested template structure, but I didn't want to have to go back and change all my templates. Grab a copy and try it out. Let me know what you think. I called it "rFastTemplate" for "recursive" but it's not really any different in functionality than the original. It's hard to come of with a name as catchy as FastTemplate and stealing the original name didn't seem quite right (not to mention the potential for confusion.

Oh, there is one thing you will have to change in your PHP code that uses the new class: the name. You will need to change

require "class.FastTemplate.php3";
$t = new FastTemplate ($template_directory);


require "class.rFastTemplate.php";
$t = new rFastTemplate ($template_directory);

Around June 1, 2001, I modified the code to no longer emit the

<!-- END DYNAMIC BLOCK: foo -->

HTML comments when it spits out the parsed template. This makes it easier to hide the fact that you are using a template and also reduces the amount of text flowing over the net (in some cases by a lot).