I've developed some libraries that generate xhtml compliant code to be used on some small projects. Here's a sample of how it works:
//=====================
class TestPage Extends Page
{
var $Frm;
function TestPage($title) {
parent:😛age($title);
$this->Frm = null;
}
function Start() {
//the code to define components to be rendered goes here
$this->AddHeader(new CSSHeader('css/style.css'));
$this->Frm = new Form('frm',$_SERVER['PHP_SELF'],'post');
$this->Frm->AddText('sometext','','','Text ','','size="50"',T_ANY);
$this->Frm->AddReset('cmreset','Clean');
$this->Frm->AddSubmit('cmsubmit','Send');
}
function Run() {
return $this->Frm->Render();
}
}
$tst=new TestPage("Test Page");
$tst->Render();
//=====================
I have a bunch of classes that do all the dirty work and provide some advanced containers, such as tabbed forms and semi-automatic database binding. All the formatting is done via CSS, and the code is run with output buffering with a error handling class.
While these libs have been quite helpful in the past, I'm starting a new project and wondering what's wrong with my approach - everyone seems to be using template engines. So what I like to know is - what am I missing? What's the big advantage of using templates?