While pondering Vincents comments on PHP templating systems, I was stuck by a flash of inspiration... A templating so good it would;
- Have XML like tags in HTML for replaceable content.
- Require no intermediate processing or specialised template language
- Support loops, if:else etc.
- Be incredibly easy for PHP developers to learn
Here's what it looks like to use...
And the Awesome Template engine...PHP Code:<?php
/* index.php */
/* Include fictional data access class */
include("classes/Dao.php");
/* Connect to database */
$dao=new Dao ("dbhost","dbname","dbuser","dbpass" );
/* Include awesome template engine */
include("classes/AwesomeTemplateEngine.class.php");
/* Fire up template engine */
$path = "/home/user/www/templates/";
$awesomeTemplateEngine= new AwesomeTemplateEngine($path);
$dataObject=$dao->fetchObject("SELECT name, email, signature FROM users ORDER BY name");
$awesomeTemplateEngine->parseTemplate($dataObject,"viewuser_template.php");
?>
<?php
/* viewuser_template.php */
?>
<html>
<head>
<title>View User</title>
</head>
<body>
<?php
foreach ($dataObject as $dataChild) {
?>
<p>Name:<?php echo ($dataChild->name); ?>
<p>Email:<?php echo ($dataChild->email); ?>
<p>Signature:<?php echo ($dataChild->name); ?>
<?php
}
?>
</body>
</html>
One for Hotscipts?PHP Code:<?php
/* AwesomeTemplateEngine.class.php */
class AwesomeTemplateEngine {
var $templatePath;
function AwesomeTemplateEngine($templatePath) {
$this->templatePath=$templatePath;
}
function parseTemplate($dataObject,$template) {
include($this->templatePath.$template);
}
}
?>![]()






Easy to work with, too 
) or you have to learn PHP, which is not restrictive (you can do anything you want) and it's not complex code for the programmer to write, because it's all native PHP functions.

Bookmarks