获取twig文件内容并传递变量

I'm planning to create a function that sends an email but my concern is that I need to get my email template and pass variables inside.

For now this is what I got :

$template = $this->view->render('./partials/email-template.twig',['name'=>'sample']);

but I'm getting this error :

Uncaught TypeError: Argument 1 passed to Slim\Views\Twig::render() must implement interface Psr\Http\Message\ResponseInterface, string given, called in C:\xampp\htdocs\master\app\Controllers\Admin\VoucherController.php on line 34

According to this thread you would need to use fetch first, e.g.

$template = $this->view->fetch('./partials/email-template.twig');
$html = $template->render(['name' => 'sample', ]);

Like the error says, the first argument has to be the $response.

Example given:

// Define named route
$app->get('/renderEmail/{name}', function ($request, $response, $args) {
    return $this->view->render($response, './partials/email-template.twig', [
        'name' => $args['name']
    ]);
})->setName('renderEmail');