本文整理汇总了PHP中Twig_Template::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Template::render方法的具体用法?PHP Twig_Template::render怎么用?PHP Twig_Template::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Template
的用法示例。
在下文中一共展示了Twig_Template::render方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* 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([]);
}
}
}
示例2: populateMessage
/**
* 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');
}
示例3: process
/**
* 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);
}
}
示例4: compile
/**
* 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');
}
}
示例5: 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);
}
示例6: _generateNewSite
/**
* 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!';
}
示例7: render
/**
* @param array $context
* @return string
* @throws \Exception
*/
public function render(array $context = [])
{
return parent::render($context);
}
示例8: renderTemplate
/**
* {@inheritdoc}
*/
protected function renderTemplate(array $context = array())
{
return $this->template->render($context);
}
示例9: output
/**
* @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;
}
示例10: output
/**
* @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;
}
示例11: compile
/**
* Compiles the template using the context.
*/
public function compile()
{
$output = $this->template->render($this->context);
$this->setContent($output);
$this->compiled = true;
}
示例12: getContent
/**
* @return string
*/
public function getContent()
{
return $this->Template->render($this->VariableList);
}
示例13: renderCharacteristics
/**
* 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]);
}
示例14: render
/**
* Returns the rendered template.
*
* @return String
*/
public function render()
{
return $this->template->render($this->parameters);
}