[Templating] added Engine::exists()

This commit is contained in:
Fabien Potencier 2010-08-29 16:09:02 +02:00
parent 0208800459
commit 478fcca88d

View File

@ -123,6 +123,28 @@ class Engine implements \ArrayAccess
return $content;
}
/**
* Returns true if the template exists.
*
* @param string $name A template name
*
* @return Boolean true if the template exists, false otherwise
*/
public function exists($name)
{
list($tpl, $options) = $this->splitTemplateName($name);
$template = $this->loader->load($tpl, $options);
if (false === $template) {
return false;
}
$this->cache[$name] = array($tpl, $options, $template);
return true;
}
/**
* Outputs a rendered template.
*