コード例 #1
0
 protected function parseTemplate($templatePathAndFilename)
 {
     $templateSource = \TYPO3\FLOW3\Utility\Files::getFileContents($templatePathAndFilename, FILE_TEXT);
     if ($templateSource === FALSE) {
         throw new \TYPO3\Fluid\View\Exception\InvalidTemplateResourceException('"' . $templatePathAndFilename . '" is not a valid template resource URI.', 1257246929);
     }
     return $this->templateParser->parse($templateSource);
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
ファイル: StandaloneViewTest.php プロジェクト: kftseng/fluid
 /**
  * @test
  */
 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();
 }
コード例 #4
0
 /**
  * Render the given template file with the given variables
  *
  * @param string $templatePathAndFilename
  * @param array $contextVariables
  * @return string
  * @throws \TYPO3\Fluid\Core\Exception
  */
 protected function renderTemplate($templatePathAndFilename, array $contextVariables)
 {
     $templateSource = \TYPO3\Flow\Utility\Files::getFileContents($templatePathAndFilename, FILE_TEXT);
     if ($templateSource === false) {
         throw new \TYPO3\Fluid\Core\Exception('The template file "' . $templatePathAndFilename . '" could not be loaded.', 1225709595);
     }
     $parsedTemplate = $this->templateParser->parse($templateSource);
     $renderingContext = $this->buildRenderingContext($contextVariables);
     return $parsedTemplate->render($renderingContext);
 }
コード例 #5
0
 /**
  * @test
  */
 public function registerNamespaceDoesNotThrowAnExceptionIfTheAliasExistAlreadyAndPointsToTheSamePhpNamespace()
 {
     $templateParser = new TemplateParser();
     $templateParser->registerNamespace('foo', 'Some\\Namespace');
     $templateParser->registerNamespace('foo', 'Some\\Namespace');
     // dummy assertion to avoid "risky test" warning
     $this->assertTrue(true);
 }