/** * Generate a page content * @param Response $response response data to use to generate output * @return string Generated output to be sent to the browser */ public function display(Response $response) { Preconditions::checkNotNull($response->getTemplate(), "Template not set"); $templateName = 'pages/' . $response->getTemplate() . '.xhtml'; $template = $this->twig->loadTemplate($templateName); $output = $template->render($response->getData()); return $output; }
/** * Generate a page content * @param Response $response response data to use to generate output * @return string Generated output to be sent to the browser */ public function display(Response $response) { if ($response->getTemplate() === null) { return; } $templateDir = FajrConfig::getDirectory('Template.Directory'); $loader = new Twig_Loader_Filesystem($templateDir); $twig = new Twig_Environment($loader, array('base_template_class' => '\\fajr\\rendering\\Template', 'strict_variables' => true)); $twig->addExtension(new Twig_Extension_Escaper()); // Register fajr's rendering extension $twig->addExtension(new Extension()); $templateName = 'pages/' . $response->getTemplate() . '.xhtml'; $template = $twig->loadTemplate($templateName); $output = $template->render($response->getData()); return $output; }
/** * Generate a page content * * @param Response $response response data to use to generate output * * @returns string Generated output to be sent to the browser */ public function display(Response $response) { Preconditions::checkNotNull($response->getTemplate(), "Template not set"); if ($response->getSkin()) { $skin = $response->getSkin(); } else { $skin = $this->defaultSkin; } $twig = $this->twigFactory->provideTwigForSkin($skin); $templateName = 'pages/' . $response->getTemplate() . '.xhtml'; $template = $twig->loadTemplate($templateName); $output = $template->render($response->getData()); return $output; }