From 478fcca88d9357779f353d07bb3ca301966e88d6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 29 Aug 2010 16:09:02 +0200 Subject: [PATCH] [Templating] added Engine::exists() --- src/Symfony/Component/Templating/Engine.php | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Symfony/Component/Templating/Engine.php b/src/Symfony/Component/Templating/Engine.php index 8b2f853968d0..6ec2d17b6770 100644 --- a/src/Symfony/Component/Templating/Engine.php +++ b/src/Symfony/Component/Templating/Engine.php @@ -123,6 +123,28 @@ public function render($name, array $parameters = array()) 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. *