How do I return a twig rendered template as part of a JSON response?

前端 未结 1 746
星月不相逢
星月不相逢 2020-12-30 23:38

I want to return an HTML snippet as well as other values in a json string, here is what I have:

$html = $this->render(\'sometemplate.html.twig\', array( \         


        
相关标签:
1条回答
  • 2020-12-31 00:09

    Use $this->renderView() instead.

    $this->render() returns a Response object, while $this->renderView() returns a string resulting from rendering a template.

    0 讨论(0)
提交回复
热议问题