Render layouts/useranswers.volt to JSON with parametrs, how to?

I have a layout useranswers.volt and i need render it to a string. I searched on google but found nothing :(

Thanks for any help!

BTW, This way not working for me:

$view = clone $this->view;
        $view->setVar("answers", $answers);
        $view->render('layouts', 'useranswers');
        $content = $view->getContent();

Unfortunately, this is only for json responses, i need render any layout for json response;

or, can you give me an example?


Hi, I'm new to Phalcon and had similar problem (needed to render HTML and put it in JSON response). I did it the following way. Perhaps, it helps.

$this->view->setRenderLevel ( View::LEVEL_ACTION_VIEW );
$this->view->render ( 'layouts', 'useranswers' );
$this->view->finish ();
$this->view->disable ();

$content_html=$this->view->getContent ();
header ( 'Content-type:application/json;charset=utf-8' );
echo "{\"content_html\":" . json_encode ( $content_html) . "}";