mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-05 22:52:49 +08:00
改进View类engine方法 如果传入字符串 则表示模板引擎名称 模板引擎参数取默认值 增加 view_replace_str 配置参数 用于设置全局 视图输出内容替换
This commit is contained in:
@@ -70,14 +70,22 @@ class View
|
||||
/**
|
||||
* 设置当前模板解析的引擎
|
||||
* @access public
|
||||
* @param array $options 引擎参数
|
||||
* @param array|string $options 引擎参数
|
||||
* @return $this
|
||||
*/
|
||||
public function engine($options = [])
|
||||
{
|
||||
$type = !empty($options['type']) ? $options['type'] : 'Think';
|
||||
if (is_string($options)) {
|
||||
$type = $options;
|
||||
$options = [];
|
||||
} else {
|
||||
$type = !empty($options['type']) ? $options['type'] : 'Think';
|
||||
}
|
||||
|
||||
$class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\view\\driver\\') . ucfirst($type);
|
||||
unset($options['type']);
|
||||
if (isset($options['type'])) {
|
||||
unset($options['type']);
|
||||
}
|
||||
$this->engine = new $class($options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user