传递模板将结果渲染到另一个方法(passing template render result to another method)
我正在尝试将$this->render()结果分配给一个方法(此方法呈现谷歌地图的infoWindow / baloon)。
我正在使用这样的方法来创建这个infoWindow:
$infoWindow->setContent(<here goes the template>);但是像这样传递:
$infoWindow->setContent($this->render('WmapFrontBundle:Place:infoWindow.html.twig'));根本不工作。 将模板分配给变量或将其内容传递给方法的正确方法是什么?
i'm trying to assign $this->render() result to a method (this method renders google map's infoWindow/baloon).
I'm using method like this to create this infoWindow:
$infoWindow->setContent(<here goes the template>);but passing it like this:
$infoWindow->setContent($this->render('WmapFrontBundle:Place:infoWindow.html.twig'));don't work at all. What's the proper way to assign template to a variable or pass it's content to a method ?
最满意答案
使用renderView() ,它只返回渲染的模板。
render()返回一个Response对象(带有渲染模板,头文件等)。
Use renderView(), it returns the rendered template only.
render() returns a Response object (with the rendered template, headers, etc).
更多推荐
发布评论