我想手动渲染树枝模板,代码如下:
$template = $this->twig->loadTemplate('MyBundle::board.html.twig'); $result = $template->render(array('entities'=>$query->getResult()));
return $result;
当我echo $result一切正常时,Chrome 会正确渲染所有 HTML 代码,但我需要$result从函数返回,然后在 twig 中渲染为{{result}},但我无法使用{{result|raw}}.
有没有其他方法可以让树枝不转义 html?