/**
  * Parse the given template and return it.
  *
  * Will cache the results for one call.
  *
  * @param string $templatePathAndFilename absolute filename of the template to be parsed
  * @return Tx_Fluid_Core_Parser_ParsedTemplateInterface the parsed template tree
  * @throws Tx_Fluid_View_Exception_InvalidTemplateResourceException
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 protected function parseTemplate($templatePathAndFilename)
 {
     $templateSource = file_get_contents($templatePathAndFilename);
     if ($templateSource === FALSE) {
         throw new Tx_Fluid_View_Exception_InvalidTemplateResourceException('"' . $templatePathAndFilename . '" is not a valid template resource URI.', 1257246929);
     }
     return $this->templateParser->parse($templateSource);
 }
 /**
  * @test
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function renderLoadsSpecifiedTemplateFileAndPassesSourceToTemplateParser()
 {
     $templatePathAndFilename = dirname(__FILE__) . '/Fixtures/StandaloneViewFixture.html';
     $expectedResult = file_get_contents($templatePathAndFilename);
     $this->view->setTemplatePathAndFilename($templatePathAndFilename);
     $this->mockTemplateParser->expects($this->once())->method('parse')->with($expectedResult);
     $this->view->render();
 }
 /**
  *
  * @param string $filePath
  * @param Array $variables
  */
 protected function renderTemplate($filePath, $variables)
 {
     if (!isset($variables['settings']['codeTemplateRootPath'])) {
         t3lib_div::devlog('Render: ' . $filePath, 'builder', 2, $variables);
         throw new Exception('No template root path configured: ' . $filePath);
     }
     if (!file_exists($variables['settings']['codeTemplateRootPath'] . $filePath)) {
         t3lib_div::devlog('No template file found: ' . $variables['settings']['codeTemplateRootPath'] . $filePath, 'extension_builder', 2, $variables);
         throw new Exception('No template file found: ' . $variables['settings']['codeTemplateRootPath'] . $filePath);
     }
     $parsedTemplate = $this->templateParser->parse(file_get_contents($variables['settings']['codeTemplateRootPath'] . $filePath));
     return $parsedTemplate->render($this->buildRenderingContext($variables));
 }
 /**
  * Renders a partial.
  *
  * @param string $partialName
  * @param string $sectionName
  * @param array $variables
  * @param Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer the View Helper Variable container to use.
  * @return string
  * @author Sebastian Kurfürst <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  * @author Robert Lemke <*****@*****.**>
  */
 public function renderPartial($partialName, $sectionName, array $variables)
 {
     $partial = $this->templateParser->parse($this->getPartialSource($partialName));
     $variableContainer = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer', $variables);
     $renderingContext = clone $this->getCurrentRenderingContext();
     $renderingContext->setTemplateVariableContainer($variableContainer);
     $this->startRendering(self::RENDERING_PARTIAL, $partial, $renderingContext);
     if ($sectionName !== NULL) {
         $output = $this->renderSection($sectionName, $variables);
     } else {
         $output = $partial->render($renderingContext);
     }
     $this->stopRendering();
     return $output;
 }
 /**
  * Render a template with variables
  *
  * @param string $filePath
  * @param array $variables
  */
 protected function renderTemplate($filePath, $variables)
 {
     //$codeTemplateRootPath = $this->getCodeTemplateRootPath();
     $variables['settings'] = $this->settings;
     //$variables['settings']['codeTemplateRootPath'] = $this->codeTemplateRootPath;
     if (!is_file($this->codeTemplateRootPath . $filePath)) {
         throw new Exception('TemplateFile ' . $this->codeTemplateRootPath . $filePath . ' not found');
     }
     $templateCode = file_get_contents($this->codeTemplateRootPath . $filePath);
     if (empty($templateCode)) {
         throw new Exception('TemplateFile ' . $this->codeTemplateRootPath . $filePath . ' has no content');
     }
     $parsedTemplate = $this->templateParser->parse($templateCode);
     $renderedContent = trim($parsedTemplate->render($this->buildRenderingContext($variables)));
     // remove all double empty lines (coming from fluid)
     return preg_replace('/^\\s*\\n[\\t ]*$/m', '', $renderedContent);
 }
 /**
  * @test
  * @author Sebastian Kurfürst <*****@*****.**>
  * @expectedException Tx_Fluid_Core_Parser_Exception
  */
 public function parseThrowsExceptionWhenStringArgumentMissing()
 {
     $templateParser = new Tx_Fluid_Core_Parser_TemplateParser();
     $templateParser->parse(123);
 }
 /**
  * Constructor. Preprocesses the $SCAN_PATTERN_NAMESPACEDECLARATION by
  * inserting the correct namespace separator.
  *
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 public function __construct()
 {
     self::$SCAN_PATTERN_NAMESPACEDECLARATION = str_replace('FLUID_NAMESPACE_SEPARATOR', preg_quote(Tx_Fluid_Fluid::NAMESPACE_SEPARATOR), self::$SCAN_PATTERN_NAMESPACEDECLARATION);
 }