1、内核更新

2、模板管理优化
This commit is contained in:
2016-12-04 16:15:43 +08:00
parent e2910d287a
commit e28383f667
10 changed files with 371 additions and 78 deletions

View File

@@ -12,6 +12,7 @@
namespace think;
use think\exception\TemplateNotFoundException;
use think\Request;
/**
* ThinkPHP分离出来的模板引擎
@@ -25,6 +26,7 @@ class Template
// 引擎配置
protected $config = [
'view_path' => '', // 模板路径
'view_base' => '',
'view_suffix' => 'html', // 默认模板文件后缀
'view_depr' => DS,
'cache_suffix' => 'php', // 默认模板缓存后缀
@@ -1061,14 +1063,18 @@ class Template
{
if ('' == pathinfo($template, PATHINFO_EXTENSION)) {
if (strpos($template, '@')) {
// 跨模块调用模板
$template = str_replace(['/', ':'], $this->config['view_depr'], $template);
$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;
list($module, $template) = explode('@', $template);
}
$template .= '.' . ltrim($this->config['view_suffix'], '.');
if (0 !== strpos($template, '/')) {
$template = str_replace(['/', ':'], $this->config['view_depr'], $template);
}
if ($this->config['view_base']) {
$module = isset($module) ? $module : Request::instance()->module();
$path = $this->config['view_base'] . ($module ? $module . DS : '');
} else {
$path = $this->config['view_path'];
}
$template = $path . $template . '.' . ltrim($this->config['view_suffix'], '.');
}
if (is_file($template)) {