/**
  * Loads the template source and render the template.
  * If "layoutName" is set in a PostParseFacet callback, it will render the file with the given layout.
  *
  * @param string $actionName If set, the view of the specified action will be rendered instead. Default is the action specified in the Request object
  * @return string Rendered Template
  * @author Sebastian Kurfürst <*****@*****.**>
  * @author Robert Lemke <*****@*****.**>
  * @api
  */
 public function render($actionName = NULL)
 {
     $this->baseRenderingContext->setControllerContext($this->controllerContext);
     $this->templateParser->setConfiguration($this->buildParserConfiguration());
     $parsedTemplate = $this->templateParser->parse($this->getTemplateSource($actionName));
     if ($this->isLayoutDefinedInTemplate($parsedTemplate)) {
         $this->startRendering(self::RENDERING_LAYOUT, $parsedTemplate, $this->baseRenderingContext);
         $parsedLayout = $this->templateParser->parse($this->getLayoutSource($this->getLayoutNameInTemplate($parsedTemplate)));
         $output = $parsedLayout->render($this->baseRenderingContext);
         $this->stopRendering();
     } else {
         $this->startRendering(self::RENDERING_TEMPLATE, $parsedTemplate, $this->baseRenderingContext);
         $output = $parsedTemplate->render($this->baseRenderingContext);
         $this->stopRendering();
     }
     return $output;
 }
 /**
  * @test
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function controllerContextCanBeReadCorrectly()
 {
     $controllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array(), array(), '', FALSE);
     $this->renderingContext->setControllerContext($controllerContext);
     $this->assertSame($this->renderingContext->getControllerContext(), $controllerContext);
 }