dongmou1964 2018-10-25 07:19
浏览 139
已采纳

获取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

  • 写回答

2条回答 默认 最新

  • dp6319 2018-10-25 08:21
    关注

    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', ]);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?