diff --git a/convention.php b/convention.php index 353fbc3a..fda103a3 100644 --- a/convention.php +++ b/convention.php @@ -64,7 +64,7 @@ return [ // 获取当前页面地址的系统变量 默认为REQUEST_URI 'url_request_uri' => 'REQUEST_URI', // URL伪静态后缀 - 'url_html_suffix' => '.html', + 'url_html_suffix' => 'html', // URL普通方式参数 用于自动生成 'url_common_param' => false, //url禁止访问的后缀 @@ -94,7 +94,7 @@ return [ // 模板路径 'view_path' => '', // 模板后缀 - 'view_suffix' => '.html', + 'view_suffix' => 'html', // 模板文件名分隔符 'view_depr' => DS, // 模板引擎普通标签开始标记 diff --git a/library/think/Template.php b/library/think/Template.php index 3124e755..eb721036 100644 --- a/library/think/Template.php +++ b/library/think/Template.php @@ -23,9 +23,9 @@ class Template // 引擎配置 protected $config = [ 'view_path' => '', // 模板路径 - 'view_suffix' => '.html', // 默认模板文件后缀 + 'view_suffix' => 'html', // 默认模板文件后缀 'view_depr' => DS, - 'cache_suffix' => '.php', // 默认模板缓存后缀 + 'cache_suffix' => 'php', // 默认模板缓存后缀 'tpl_deny_func_list' => 'echo,exit', // 模板引擎禁用函数 'tpl_deny_php' => false, // 默认模板引擎是否禁用PHP原生代码 'tpl_begin' => '{', // 模板引擎普通标签开始标记 @@ -179,7 +179,7 @@ class Template } $template = $this->parseTemplateFile($template); if ($template) { - $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($template) . $this->config['cache_suffix']; + $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($template) . '.' . ltrim($this->config['cache_suffix'], '.'); if (!$this->checkCache($cacheFile)) { // 缓存无效 重新模板编译 $content = file_get_contents($template); @@ -216,7 +216,7 @@ class Template if ($config) { $this->config($config); } - $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($content) . $this->config['cache_suffix']; + $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($content) . '.' . ltrim($this->config['cache_suffix'], '.'); if (!$this->checkCache($cacheFile)) { // 缓存无效 模板编译 $this->compiler($content, $cacheFile); @@ -1051,11 +1051,12 @@ class Template if (strpos($template, '@')) { // 跨模块调用模板 $template = str_replace(['/', ':'], $this->config['view_depr'], $template); - $template = APP_PATH . str_replace('@', '/' . basename($this->config['view_path']) . '/', $template) . $this->config['view_suffix']; + $template = APP_PATH . str_replace('@', '/' . basename($this->config['view_path']) . '/', $template); } else { $template = str_replace(['/', ':'], $this->config['view_depr'], $template); - $template = $this->config['view_path'] . $template . $this->config['view_suffix']; + $template = $this->config['view_path'] . $template; } + $template .= '.' . ltrim($this->config['view_suffix'], '.'); } if (is_file($template)) { // 记录模板文件的更新时间 diff --git a/library/think/view/driver/Php.php b/library/think/view/driver/Php.php index 9b74d1df..9ab33119 100644 --- a/library/think/view/driver/Php.php +++ b/library/think/view/driver/Php.php @@ -21,7 +21,7 @@ class Php // 模板起始路径 'view_path' => '', // 模板文件后缀 - 'view_suffix' => '.php', + 'view_suffix' => 'php', // 模板文件名分隔符 'view_depr' => DS, ]; @@ -109,7 +109,7 @@ class Php $template = str_replace('.', DS, CONTROLLER_NAME) . $depr . $template; } } - return $path . $template . $this->config['view_suffix']; + return $path . $template . '.' . ltrim($this->config['view_suffix'], '.'); } } diff --git a/library/think/view/driver/Think.php b/library/think/view/driver/Think.php index 1b35ed41..ac7a84b0 100644 --- a/library/think/view/driver/Think.php +++ b/library/think/view/driver/Think.php @@ -24,7 +24,7 @@ class Think // 模板起始路径 'view_path' => '', // 模板文件后缀 - 'view_suffix' => '.html', + 'view_suffix' => 'html', // 模板文件名分隔符 'view_depr' => DS, // 是否开启模板编译缓存,设为false则每次都会重新编译 @@ -114,7 +114,7 @@ class Think $template = str_replace('.', DS, CONTROLLER_NAME) . $depr . $template; } } - return $path . $template . $this->config['view_suffix']; + return $path . $template . '.' . ltrim($this->config['view_suffix'], '.'); } public function __call($method, $params)