Exemplo n.º 1
0
 /**
  * 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 \F3\Fluid\Core\Parser\ParsedTemplateInterface the parsed template tree
  * @throws \F3\Fluid\View\Exception\InvalidTemplateResourceException
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 protected function parseTemplate($templatePathAndFilename)
 {
     $templateSource = \F3\FLOW3\Utility\Files::getFileContents($templatePathAndFilename, FILE_TEXT);
     if ($templateSource === FALSE) {
         throw new \F3\Fluid\View\Exception\InvalidTemplateResourceException('"' . $templatePathAndFilename . '" is not a valid template resource URI.', 1257246929);
     }
     return $this->templateParser->parse($templateSource);
 }
 /**
  * Render the given template file with the given variables
  *
  * @param string $templatePathAndFilename
  * @param array $contextVariables
  * @return string
  * @author Christopher Hlubek <*****@*****.**>
  */
 protected function renderTemplate($templatePathAndFilename, $contextVariables)
 {
     $templateSource = \F3\FLOW3\Utility\Files::getFileContents($templatePathAndFilename, FILE_TEXT);
     if ($templateSource === FALSE) {
         throw new \F3\Fluid\Core\RuntimeException('The template file "' . $templatePathAndFilename . '" could not be loaded.', 1225709595);
     }
     $parsedTemplate = $this->templateParser->parse($templateSource);
     $renderingContext = $this->buildRenderingContext($contextVariables);
     return $parsedTemplate->render($renderingContext);
 }