传递模板将结果传递给另一个方法

时间:2011-09-07 21:00:41

标签: php symfony

我正在尝试将$this->render()结果分配给方法(此方法呈现谷歌地图的infoWindow / baloon)。

我正在使用这样的方法来创建这个infoWindow:

$infoWindow->setContent(<here goes the template>);

但是这样传递:

$infoWindow->setContent($this->render('WmapFrontBundle:Place:infoWindow.html.twig'));

根本不工作。将模板分配给变量或将其内容传递给方法的正确方法是什么?

1 个答案:

答案 0 :(得分:10)

使用renderView(),它仅返回渲染的模板。

render()返回一个Response对象(带有渲染的模板,标题等)。

相关问题