From 9918d4c02ab1d3e0d394bc557a092f11ca3497f2 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 19 Apr 2018 17:05:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=A8=A1=E6=9D=BF=E5=BC=95?= =?UTF-8?q?=E6=93=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/template/driver/File.php | 10 +++++++++- library/think/view/driver/Php.php | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/library/think/template/driver/File.php b/library/think/template/driver/File.php index bf3d22af..f7fa8c89 100644 --- a/library/think/template/driver/File.php +++ b/library/think/template/driver/File.php @@ -44,7 +44,15 @@ class File { if (!empty($vars) && is_array($vars)) { // 模板阵列变量分解成为独立变量 - extract($vars, EXTR_OVERWRITE); + if (isset($vars['cacheFile'])) { + $_think_cacheFile = $cacheFile; + $cacheFile = $vars['cacheFile']; + unset($vars['cacheFile'], $vars['_think_cacheFile']); + extract($vars, EXTR_OVERWRITE); + include $_think_cacheFile; + return; + } + extract($vars); } //载入模版缓存文件 include $cacheFile; diff --git a/library/think/view/driver/Php.php b/library/think/view/driver/Php.php index 029ee694..47c9dc10 100644 --- a/library/think/view/driver/Php.php +++ b/library/think/view/driver/Php.php @@ -74,6 +74,8 @@ class Php App::$debug && Log::record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]', 'info'); if (isset($data['template'])) { $__template__ = $template; + $template = $data['template']; + unset($data['template'], $data['__template__']); extract($data, EXTR_OVERWRITE); include $__template__; } else { @@ -93,6 +95,8 @@ class Php { if (isset($data['content'])) { $__content__ = $content; + $content = $data['content']; + unset($data['content'], $data['__content__']); extract($data, EXTR_OVERWRITE); eval('?>' . $__content__); } else {