Symfony渲染模板到字符串

Sej*_*nus 3 php rendering symfony1

有没有办法在行动中将完全渲染的模板(有或没有布局)作为字符串?

即沿着这些方向的东西:

public function executeMyAction()
{
   $this->variable1 = 'foo';
   $this->variable2 = 'bar';

   // renders template using assigned variables, partials, layouts, etc. as if it was for    output to browser, but assigns html to string
   $renderedTemplate = $this->renderTemplateToString();
}
Run Code Online (Sandbox Code Playgroud)

PS我知道这个问题,但是答案提供给我的目的并没有那么好.链接不起作用,getPartial获取模板文件而不进行渲染.