mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
优化Template类
This commit is contained in:
@@ -64,14 +64,16 @@ class Template
|
|||||||
*/
|
*/
|
||||||
public function __construct(array $config = [])
|
public function __construct(array $config = [])
|
||||||
{
|
{
|
||||||
$this->config['cache_path'] = TEMP_PATH;
|
$this->config['cache_path'] = TEMP_PATH;
|
||||||
$this->config = array_merge($this->config, $config);
|
$this->config = array_merge($this->config, $config);
|
||||||
|
|
||||||
$this->config['taglib_begin_origin'] = $this->config['taglib_begin'];
|
$this->config['taglib_begin_origin'] = $this->config['taglib_begin'];
|
||||||
$this->config['taglib_end_origin'] = $this->config['taglib_end'];
|
$this->config['taglib_end_origin'] = $this->config['taglib_end'];
|
||||||
$this->config['taglib_begin'] = $this->stripPreg($this->config['taglib_begin']);
|
|
||||||
$this->config['taglib_end'] = $this->stripPreg($this->config['taglib_end']);
|
$this->config['taglib_begin'] = preg_quote($this->config['taglib_begin'], '/');
|
||||||
$this->config['tpl_begin'] = $this->stripPreg($this->config['tpl_begin']);
|
$this->config['taglib_end'] = preg_quote($this->config['taglib_end'], '/');
|
||||||
$this->config['tpl_end'] = $this->stripPreg($this->config['tpl_end']);
|
$this->config['tpl_begin'] = preg_quote($this->config['tpl_begin'], '/');
|
||||||
|
$this->config['tpl_end'] = preg_quote($this->config['tpl_end'], '/');
|
||||||
|
|
||||||
// 初始化模板编译存储器
|
// 初始化模板编译存储器
|
||||||
$type = $this->config['compile_type'] ? $this->config['compile_type'] : 'File';
|
$type = $this->config['compile_type'] ? $this->config['compile_type'] : 'File';
|
||||||
@@ -79,20 +81,6 @@ class Template
|
|||||||
$this->storage = new $class();
|
$this->storage = new $class();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符串替换 避免正则混淆
|
|
||||||
* @access private
|
|
||||||
* @param string $str
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function stripPreg($str)
|
|
||||||
{
|
|
||||||
return str_replace(
|
|
||||||
['{', '}', '(', ')', '|', '[', ']', '-', '+', '*', '.', '^', '?'],
|
|
||||||
['\{', '\}', '\(', '\)', '\|', '\[', '\]', '\-', '\+', '\*', '\.', '\^', '\?'],
|
|
||||||
$str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板变量赋值
|
* 模板变量赋值
|
||||||
* @access public
|
* @access public
|
||||||
|
|||||||
Reference in New Issue
Block a user