From baa371cbe97ab1f5d11882e8e861cca964c21bbb Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 14 Mar 2016 21:59:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BView=E7=B1=BB=E5=AF=B9?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=BC=95=E6=93=8E=E7=9A=84=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/View.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/library/think/View.php b/library/think/View.php index 0c623333..140f7489 100644 --- a/library/think/View.php +++ b/library/think/View.php @@ -52,10 +52,6 @@ class View public function __construct(array $config = []) { $this->config($config); - if (empty($this->config['view_path']) && defined('VIEW_PATH')) { - $this->config['view_path'] = VIEW_PATH; - } - $this->engine($this->config['view_engine']['type'], $this->config['view_engine']); } /** @@ -234,12 +230,18 @@ class View */ private function parseTemplate($template) { + if (is_null($this->engine)) { + // 初始化模板引擎 + if (empty($this->config['view_path']) && defined('VIEW_PATH')) { + $this->config['view_path'] = VIEW_PATH; + } + $this->engine($this->config['view_engine']['type'], $this->config['view_engine']); + } + if (is_file($template)) { return realpath($template); } - if (strpos($template, $this->config['view_suffix'])) { - return $template; - } + $depr = $this->config['view_depr']; $template = str_replace(['/', ':'], $depr, $template); $theme = $this->getTemplateTheme();