What are the advantages and disadvantages of using template classes like Smarty versus creating your own template system in PHP?

When deciding between using template classes like Smarty or creating your own template system in PHP, the advantage of using Smarty is that it provides a more robust and feature-rich solution out of the box, with built-in caching, template inheritance, and other advanced features. On the other hand, creating your own template system allows for more customization and control over the code, but may require more time and effort to implement all the necessary functionality.

// Using Smarty template engine
require_once('smarty/Smarty.class.php');

$smarty = new Smarty();
$smarty->template_dir = 'templates';
$smarty->compile_dir = 'templates_c';

$smarty->assign('name', 'John Doe');
$smarty->display('index.tpl');