i wrote my own templating system in OOP and i always use it for every task I undertake.
i obviously don't expect n00bs to grasp it straight away, but by making them aware that it's there and it's what they should aim for never does any harm 🙂
for beginner programmers, I think a good method is to have all you variables above the html, and include the html from another file:
$this = 'hi';
$var = 'howdy';
echo <<<EOF
$var is another word for $this hmm said characters &$*"%"!
EOF;
then use functions, possibly just going straight to functions couldn't be bad. then I prefer to use OOP in order to do templates:
$TEMP = new template;
class template{
var $morestuff = 'hmm said stuff';
function dotemplate(){
global $stuff;
require('./Skinsfile.php');
return Skin( $this );
}
}
then have Skinsfile.php:
function Skin( $obj ){
return <<<EOF
hmm said {$obj->stuff}
98387&^&"^%£*
{$obj->morestuff}
EOF;
}
🙂