In what scenarios or types of projects would it be more beneficial to use a lightweight, custom template system over a more feature-rich option like Smarty in PHP development?

In scenarios where the project requires a simple and lightweight solution, using a custom template system may be more beneficial than a feature-rich option like Smarty. Custom template systems are easier to customize and maintain, making them ideal for smaller projects or projects with specific requirements that may not be met by larger template engines.

// Custom lightweight template system example
function render_template($template, $data) {
    extract($data);
    ob_start();
    include $template;
    return ob_get_clean();
}

// Usage
$template = 'templates/my_template.php';
$data = ['title' => 'Hello, World!', 'content' => 'This is a custom template system.'];
echo render_template($template, $data);