模板引擎参数采用template二级配置

This commit is contained in:
thinkphp
2016-03-15 18:34:05 +08:00
parent f043633ff4
commit 3cbd5d1b7c

View File

@@ -25,10 +25,6 @@ class View
protected $config = [ protected $config = [
// 模板主题 // 模板主题
'theme_on' => false, 'theme_on' => false,
// 是否自动侦测主题
'auto_detect_theme' => false,
// 自动侦测主题的URL变量
'var_theme' => 't',
// 默认主题 开启模板主题有效 // 默认主题 开启模板主题有效
'default_theme' => 'default', 'default_theme' => 'default',
// 视图文件路径 // 视图文件路径
@@ -44,7 +40,7 @@ class View
// 视图驱动命名空间 // 视图驱动命名空间
'namespace' => '\\think\\view\\driver\\', 'namespace' => '\\think\\view\\driver\\',
// 模板引擎配置参数 // 模板引擎配置参数
'view_engine' => [ 'template' => [
'type' => 'think', 'type' => 'think',
], ],
]; ];
@@ -142,14 +138,13 @@ class View
public function theme($theme) public function theme($theme)
{ {
if (true === $theme) { if (true === $theme) {
// 自动侦测 // 启用主题
$this->config['theme_on'] = true; $this->config['theme_on'] = true;
$this->config['auto_detect_theme'] = true;
} elseif (false === $theme) { } elseif (false === $theme) {
// 关闭主题 // 关闭主题
$this->config['theme_on'] = false; $this->config['theme_on'] = false;
} else { } else {
// 指定模板主题 // 指定主题
$this->config['theme_on'] = true; $this->config['theme_on'] = true;
$this->theme = $theme; $this->theme = $theme;
} }
@@ -185,7 +180,7 @@ class View
} }
if (is_null($this->engine)) { if (is_null($this->engine)) {
// 初始化模板引擎 // 初始化模板引擎
$this->engine($this->config['view_engine']['type'], $this->config['view_engine']); $this->engine($this->config['template']['type'], $this->config['template']);
} }
// 页面缓存 // 页面缓存
ob_start(); ob_start();