Savant3 differs from the other templating solutions introduced in this article in that it does not require users to learn a new syntax, instead using PHP as the templating language. You might wonder whether this defeats the stated purpose of separating PHP logic from the website's presentation, however by distilling the PHP code down to a few presentation-specific methods you are effectively accomplishing the same goals set forth by the competing solutions, while simultaneously saving yourself the trouble of learning an engine-specific syntax. For example the following PHP script will ready a template for outputting an array of video games:
This syntax probably looks quite familiar, save for perhaps the reference to the eprint() method. This method is a Savant3 method which will automatically escape the output before inserting it into the template, lessening the possibility of cross-site scripting attacks.
Learn more about Savant3 at
phpsavant.com.
PHPTal is a PHP-based implementation of
Zope Page Templates, a Web page generation tool used by the Python-based Web application server
Zope. PHPTal differs from the other templating engines discussed in this article in that it implements an XML-based approach. For instance, the following PHPTal template is used to iterate over an array:
Learn more about PHPTal at
phptal.org.
Are you using a PHP templating engine not included in this list? Tell us about it in the comments!