微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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().

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐