/**
  * Renders a partial.
  *
  * @param string $partialName
  * @param string $sectionName
  * @param array $variables
  * @return string
  */
 public function renderPartial($partialName, $sectionName, array $variables)
 {
     if (!isset($this->partialIdentifierCache[$partialName])) {
         $this->partialIdentifierCache[$partialName] = $this->getPartialIdentifier($partialName);
     }
     $partialIdentifier = $this->partialIdentifierCache[$partialName];
     if ($this->templateCompiler->has($partialIdentifier)) {
         $parsedPartial = $this->templateCompiler->get($partialIdentifier);
     } else {
         $parsedPartial = $this->templateParser->parse($this->getPartialSource($partialName));
         if ($parsedPartial->isCompilable()) {
             $this->templateCompiler->store($partialIdentifier, $parsedPartial);
         }
     }
     /** @var $variableContainer TemplateVariableContainer **/
     $variableContainer = $this->objectManager->get('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer', $variables);
     $renderingContext = clone $this->getCurrentRenderingContext();
     $renderingContext->injectTemplateVariableContainer($variableContainer);
     $this->startRendering(self::RENDERING_PARTIAL, $parsedPartial, $renderingContext);
     if ($sectionName !== NULL) {
         $output = $this->renderSection($sectionName, $variables);
     } else {
         $output = $parsedPartial->render($renderingContext);
     }
     $this->stopRendering();
     return $output;
 }
Esempio n. 2
0
 /**
  * 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
  * @api
  */
 public function render($actionName = NULL)
 {
     $this->templateParser->setConfiguration($this->buildParserConfiguration());
     $templateIdentifier = $this->getTemplateIdentifier($actionName);
     if ($this->templateCompiler->has($templateIdentifier)) {
         $parsedTemplate = $this->templateCompiler->get($templateIdentifier);
     } else {
         $parsedTemplate = $this->templateParser->parse($this->getTemplateSource($actionName));
         if ($parsedTemplate->isCompilable()) {
             $this->templateCompiler->store($templateIdentifier, $parsedTemplate);
         }
     }
     if ($parsedTemplate->hasLayout()) {
         $layoutName = $parsedTemplate->getLayoutName($this->baseRenderingContext);
         $layoutIdentifier = $this->getLayoutIdentifier($layoutName);
         if ($this->templateCompiler->has($layoutIdentifier)) {
             $parsedLayout = $this->templateCompiler->get($layoutIdentifier);
         } else {
             $parsedLayout = $this->templateParser->parse($this->getLayoutSource($layoutName));
             if ($parsedLayout->isCompilable()) {
                 $this->templateCompiler->store($layoutIdentifier, $parsedLayout);
             }
         }
         $this->startRendering(self::RENDERING_LAYOUT, $parsedTemplate, $this->baseRenderingContext);
         $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;
 }