I've been looking over a few template engines (the ones listed on freshmeat and sourceforge) and I liked bits of lots of them. I say that we create our own, probably as a class, and I'll even explain why.
FastTemplate, XTemplate, QuickTemplate and others just do variable substitution. The biggest problem with that is you can't call functions. This still might be an obscure or abstract idea, so wish me luck in explaining it.
Let's say you want to see a list of all your mail in the inbox. You would want the template engine to put a header on your page (static), footer (static), and a list of messages (semi-static). But what if you want to alter that template so that on nearly any page you can get 5 or so messages at the top of your screen. It may be a bit odd, but even on the compose screen.
The easiest way would be to
- include another template that ...
- runs a function when needed to fetch specific message headers
- Loops through the arrays returned, coloring alternating rows
At least including another template would be ideal. In FastTemplate, I didn't see the "include" stuff. Only variable substitution. So, you would have to make a different template for different amounts of messages shown, or recursively parse a "row" template a few times.
When looking at TARP (http://tarp.fifthace.com/), I did really like the fact that it could create objects when needed and use them appropriately. What I didn't like is that it seems to be integrated into the web server, and therefore not really for us. We want it to be trivial to install SquirrelMail (a very wise decision).
So, that is why I think that we should create our own. Also, I think that it should be a class, that way we can use it a lot like FastTemplate and can distribute it separately so others can use our template engine.
As an aside, I am going to start work on the template engine now. I'm going to need something like this for my virtual classroom software. If this sounds like a good thing, I'd more than willingly share my code (if asked).
Tyler Akins tyler@...