Difference between revisions of "Template Engines"

From GeeklogWiki
Jump to: navigation, search
 
 
Line 1: Line 1:
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.
+
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...sort of.
  
The default template engine for Geeklog 2 is going to be [http://pear.php.net/package/HTML_Template_Flexy 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.
+
The default template engine for Geeklog 2 is going to be [http://pear.php.net/package/HTML_Template_Flexy 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 a little work, any 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 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, [http://www.groklaw.net 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.
+
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 uses a lot of regular expressions which perform poorly and, on larger Geeklog sites (say, [http://www.groklaw.net 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.  Flexy also has native translation support.  Other template engines support some of these 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 me with any complaints.
  
 
I am confident the open-minded will find Flexy a quite capable templating system.
 
I am confident the open-minded will find Flexy a quite capable templating system.

Latest revision as of 18:05, 16 May 2005

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...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 a little work, any 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 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 uses a lot of regular expressions which perform poorly and, on larger Geeklog sites (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. Flexy also has native translation support. Other template engines support some of these 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 me with any complaints.

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