From 516873fe13872d8655ba3b33434f3cd7d23bd97e Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Wed, 7 Sep 2011 03:10:41 -0700 Subject: [PATCH] Added method to check if template file exists. --- flight/View.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/flight/View.php b/flight/View.php index 1dfbac8..2059ef0 100644 --- a/flight/View.php +++ b/flight/View.php @@ -106,11 +106,22 @@ class View { * Displays escaped output. * * @param string $str String to escape + * @return string Escaped string */ public function e($str) { echo htmlentities($str); } + /** + * Checks if a template file exists. + * + * @param string $file Template file + * @return bool Template file exists + */ + public function exists($file) { + return file_exists($this->path.'/'.((substr($file, -4) == '.php') ? $file : $file.'.php')); + } + /** * Loads and executes view helper functions. *