php – Symfony将模板渲染为字符串

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

即沿着这些方向的东西:

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();
}

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

解决方法:

你应该试试sfController::getPresentationFor().

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...