diff --git a/library/think/view/driver/Php.php b/library/think/view/driver/Php.php index 9ab33119..3063bc02 100644 --- a/library/think/view/driver/Php.php +++ b/library/think/view/driver/Php.php @@ -55,9 +55,12 @@ class Php */ public function fetch($template, $data = []) { + if (!is_file($template)) { + // 获取模板文件名 + $template = $this->parseTemplate($template); + } // 模板不存在 抛出异常 - $template = $this->exists($template); - if (!$template) { + if (!is_file($template)) { throw new Exception('template file not exists:' . $template, 10700); } // 记录视图信息 diff --git a/library/think/view/driver/Think.php b/library/think/view/driver/Think.php index ac7a84b0..8eb85e26 100644 --- a/library/think/view/driver/Think.php +++ b/library/think/view/driver/Think.php @@ -52,7 +52,7 @@ class Think // 获取模板文件名 $template = $this->parseTemplate($template); } - return is_file($template) ? $template : false; + return is_file($template); } /** @@ -65,9 +65,12 @@ class Think */ public function fetch($template, $data = [], $config = []) { + if (!is_file($template)) { + // 获取模板文件名 + $template = $this->parseTemplate($template); + } // 模板不存在 抛出异常 - $template = $this->exists($template); - if (!$template) { + if (!is_file($template)) { throw new Exception('template file not exists:' . $template, 10700); } // 记录视图信息