diff --git a/src/Symfony/Component/Templating/Engine.php b/src/Symfony/Component/Templating/Engine.php index 8b2f853968..6ec2d17b67 100644 --- a/src/Symfony/Component/Templating/Engine.php +++ b/src/Symfony/Component/Templating/Engine.php @@ -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. *