/** * Render the current request action */ public function render() { if (isset($this->controllerTemplate)) { if (isset($this->actionTemplate)) { return $this->controllerTemplate->render(['actionTemplate' => $this->actionTemplate->render([])]); } else { return $this->controllerTemplate->render([]); } } else { if (isset($this->actionTemplate)) { return $this->actionTemplate->render([]); } } }
/** * Fills in message using blocks from a template (`body`, `subject`, `from`). * If there is no `body` block then whole template will be used. * If there is no `subject` or `from` block then corresponding default value will be used. * @param \Swift_Message $message * @param \Twig_Template $templateContent * @param array $data */ protected function populateMessage(\Swift_Message $message, \Twig_Template $templateContent, $data) { $body = $templateContent->hasBlock('body') ? $templateContent->renderBlock('body', $data) : $templateContent->render($data); $subject = $templateContent->hasBlock('subject') ? $templateContent->renderBlock('subject', $data) : $this->defaultSubject; $from = $templateContent->hasBlock('from') ? $templateContent->renderBlock('from', $data) : $this->defaultFrom; $message->setFrom($from)->setSubject($subject)->setBody($body, 'text/html', 'utf-8'); }
/** * Processes the template with data to produce the final output. * * @param mixed $data The data that will be used to process the view. * * @return string Returns processed output string. */ public function process($data = array()) { try { return $this->template->render($data); } catch (\Exception $caught) { throw new ParserException("Template process error: " . $caught->getMessage(), 0, $caught); } }
/** * Compiles the template using the context. */ public function compile() { if ($this->stopwatch) { $this->stopwatch->start('bolt.render', 'template'); } $output = $this->template->render($this->context); $this->setContent($output); $this->compiled = true; if ($this->stopwatch) { $this->stopwatch->stop('bolt.render'); } }
/** {@inheritdoc} */ public function render(array $context) { foreach ($context as &$var) { if ($var instanceof \ModelCriteria) { $var = new \Curry_Twig_QueryWrapper($var); } if (is_object($var) && method_exists($var, 'toTwig')) { $var = $var->toTwig(); } } unset($var); return parent::render($context); }
/** * Turn raw files into entries * */ protected function _generateNewSite() { // Load templates $TplPost = $this->_twig->loadTemplate('post.html.twig'); // Reiterate files $pages = 0; foreach ($this->_posts as $id => $post) { // Assert directory exists $dirName = $this->_assertDateDirectoryExists($post['depth']); // Open and clear file content $fileContent = file($this->_makeDirPath('posts/' . $post['file'])); foreach ($fileContent as $n => $line) { if (isset($line[0]) && $line[0] == '@') { unset($fileContent[$n]); } else { break; } } $fileContent = trim(implode("\n", $fileContent)); // Defaultise post description if (strlen($post['description']) == 0) { $post['description'] = $this->_description; } // Render template file_put_contents($dirName . $post['fancyName'], $this->_tplWrapper->render(array('name' => $this->_name, 'author' => $this->_author, 'title' => $post['title'], 'date' => $post['date'], 'description' => $post['description'], 'domain' => $this->_domain, 'path' => $this->_path, 'post' => $post, 'next' => isset($this->_posts[$id + 1]) ? $this->_posts[$id + 1] : false, 'previous' => isset($this->_posts[$id - 1]) ? $this->_posts[$id - 1] : false, 'page' => $TplPost->render(array('name' => $this->_name, 'author' => $this->_author, 'path' => $this->_path, 'post' => $post, 'next' => isset($this->_posts[$id + 1]) ? $this->_posts[$id + 1] : false, 'previous' => isset($this->_posts[$id - 1]) ? $this->_posts[$id - 1] : false, 'title' => $post['title'], 'description' => $post['description'], 'date' => $post['date'], 'domain' => $this->_domain, 'path' => $this->_path, 'link' => $post['link'], 'text' => $this->_parseText($fileContent)))))); // Increase counter $pages++; } // Generate Index and Archive foreach (array('index', 'archive') as $page) { $TplIndex = $this->_twig->loadTemplate($page . '.html.twig'); file_put_contents($this->_makeDirPath('site/' . $page . '.html'), $this->_tplWrapper->render(array('special' => $page, 'name' => $this->_name, 'author' => $this->_author, 'description' => $this->_description, 'domain' => $this->_domain, 'path' => $this->_path, 'page' => $TplIndex->render(array('name' => $this->_name, 'author' => $this->_author, 'description' => $this->_description, 'domain' => $this->_domain, 'path' => $this->_path, 'posts' => $this->_posts))))); } // Generate RSS $TplRss = $this->_twig->loadTemplate('rss.xml.twig'); file_put_contents($this->_makeDirPath('site/rss.xml'), $TplRss->render(array('name' => $this->_name, 'author' => $this->_author, 'description' => $this->_description, 'domain' => $this->_domain, 'path' => $this->_path, 'posts' => $this->_posts, 'pubDate' => date('r', reset(array_keys($this->_posts))), 'lastBuildDate' => date('r')))); echo "\nWebsite containing " . ($pages == 1 ? 'one page' : $pages . ' pages') . ' has been generated!'; }
/** * @param array $context * @return string * @throws \Exception */ public function render(array $context = []) { return parent::render($context); }
/** * {@inheritdoc} */ protected function renderTemplate(array $context = array()) { return $this->template->render($context); }
/** * @param FieldDescriptionInterface $fieldDescription * @param \Twig_Template $template * @param array $parameters * * @return string */ public function output(FieldDescriptionInterface $fieldDescription, \Twig_Template $template, array $parameters, \Twig_Environment $environment) { $content = $template->render($parameters); if ($environment->isDebug()) { $commentTemplate = <<<EOT <!-- START fieldName: %s template: %s compiled template: %s --> %s <!-- END - fieldName: %s --> EOT; return sprintf($commentTemplate, $fieldDescription->getFieldName(), $fieldDescription->getTemplate(), $template->getTemplateName(), $content, $fieldDescription->getFieldName()); } return $content; }
/** * @param FieldDescriptionInterface $fieldDescription * @param \Twig_Template $template * @param array $parameters * * @return string */ public function output(FieldDescriptionInterface $fieldDescription, \Twig_Template $template, array $parameters = array()) { $content = $template->render($parameters); if ($this->environment->isDebug()) { return sprintf("\n<!-- START \n fieldName: %s\n template: %s\n compiled template: %s\n -->\n%s\n<!-- END - fieldName: %s -->", $fieldDescription->getFieldName(), $fieldDescription->getTemplate(), $template->getTemplateName(), $content, $fieldDescription->getFieldName()); } return $content; }
/** * Compiles the template using the context. */ public function compile() { $output = $this->template->render($this->context); $this->setContent($output); $this->compiled = true; }
/** * @return string */ public function getContent() { return $this->Template->render($this->VariableList); }
/** * Renders a characteristics view table. * * @param CharacteristicsInterface $characteristics * @param array $options * * @return string */ public function renderCharacteristics(CharacteristicsInterface $characteristics, array $options = []) { $options = array_merge(['table_class' => 'table table-striped table-bordered table-condensed ekyna-characteristics', 'highlight_inherited' => false, 'display_group' => null], $options); return $this->template->render(['view' => $this->manager->createView($characteristics, $options['display_group']), 'options' => $options]); }
/** * Returns the rendered template. * * @return String */ public function render() { return $this->template->render($this->parameters); }