title: How do I render a view into a variable in ZF2?
body: <p>In a class file, I am trying to render a .phtml file into a variable and pass the HTML output of that .phtml file to a variable in another ViewModel. How do I do this in ZF2?</p>
  
  <p>The code I have so far is, which doesn't really seem to work:</p>
  
  <pre><code>$layout = new ViewModel();
  $layout-&gt;setTemplate('myPhtmlFile.phtml');
  $layout-&gt;setTerminal(true);
  
  $viewModel = new ViewModel();
  $viewModel-&gt;setVariable('formBody', $layout);
  </code></pre>