Now I am doing so:
public function indexAction() {
...
$view = new ViewModel(array(
\'foo\' => \'bar\',
));
return $view;
}
Complementing the answer, with layout included...
public function IndexAction() {
...
$viewRender = $this->getServiceLocator()->get('ViewRenderer');
$layout = new ViewModel();
$layout->setTemplate("layout/main");
$layout->setVariable("content", $viewRender->render($viewModel));
$html = $viewRender->render($layout);
...
}
Try this:
public function IndexAction()
{
...
$viewRender = $this->getServiceLocator()->get('ViewRenderer');
$html = $viewRender->render($viewModel);
...
}