Template Engines

From GeeklogWiki
Revision as of 15:40, 16 May 2005 by Tony (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Talk to PHP developers and almost all of them have a strong opinion on what the best HTML Template Engine is. Coke, Pepsi, Shasta...who cares? Well, we don't. Well....sort of.

The default template engine for Geeklog 2 is going to be PEAR::HTML_Template_Flexy. I could go into the reasoning for this decision but I won't because, frankly, it doesn't matter. While Flexy is the default engine, with little work, a GL2 developer could create MVC-based views that used any template engine they wanted. However, I will say this...choosing one other than Flexy should be given some serious thought because as soon as you start using another engine, you are going to 'upset' theme developers who would now have to learn yet another template engine. So while the architecture for Geeklog 2 supports the ability to use other template engines, we will strongly discourge using anything other than Flexy.

For those of you out there that simply want to know why the 1.3.x template engine is being replaced and don't care too much what is replacing it, the answer is simple. The 1.3.x engine using a lot of regular expressions which perform poorly and, on larger Geeklog site (say, Groklaw), it has consumed memory to the point of exhaustion. Flexy gets around this by taking an HTML template and 'compiling' it into PHP code. The 'compiled' PHP version of a template runs significantly faster and doesn't have the same memory problems. Other reasons for using Flexy is it supports control stuctures (FOR loops, IF statements) and allows for methods on the view that uses it to be called. Other templates support similar features, but Flexy is the one we chose. If you aren't happy about this decision feel free to curse my name but, please, don't bother contacting with any complaints.

I am confident the open-minded will find Flexy a quite capable templating system.