Reputation: 21
I want to save twig render output to variable and then write into a file. Normally, Twig in other projects would behave like this:
$bob = $this->render('index.html.twig',[
'foo' => $foo,
'token' => $token
]);
$bob->getContent();
However, with UserFrosting framework, $this->_app->render does not return any string and it echo the output right away.
For example:
$output=$this->_app->render('proposal/create-seo-proposal.twig');
Is there any way to capture the output generated by $this->_app->render ?
Upvotes: 1
Views: 355
Reputation: 21
spent sometimes looking into the UserFrosting code.
Realize $app is created on Slim Framework with Twig.
Therefore, Slim Framework got a few options to choose beside render function.
Therefore, this works:
$output=$this->_app->view->fetch(template-name.twig)
then save $output in a file or store it somewhere.
Cheers,
Upvotes: 1