Skip to content

Commit

Permalink
[Templating] added an Engine::load() method
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Nov 21, 2010
1 parent e3551b5 commit cbb22b4
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/Symfony/Component/Templating/Engine.php
Expand Up @@ -140,17 +140,34 @@ public function render($name, array $parameters = array())
*/
public function exists($name)
{
list($tpl, $options) = $this->splitTemplateName($name);
return false !== $this->load($name);
}

$template = $this->loader->load($tpl, $options);
/**
* Returns true if the template exists.
*
* @param string $name A template name
*
* @return Boolean true if the template exists, false otherwise
*/
public function load($name)
{
if (isset($this->cache[$name])) {
list($tpl, $options, $template) = $this->cache[$name];
} else {
list($tpl, $options) = $this->splitTemplateName($name);

if (false === $template) {
return false;
}
// load
$template = $this->loader->load($tpl, $options);

$this->cache[$name] = array($tpl, $options, $template);
if (false === $template) {
return false;
}

$this->cache[$name] = array($tpl, $options, $template);
}

return true;
return $template;
}

/**
Expand Down

0 comments on commit cbb22b4

Please sign in to comment.