1

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 ?

Theodore
  • 21
  • 2

1 Answers1

1

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,

Theodore
  • 21
  • 2