mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-09-02 21:41:36 +08:00
更新核心文件
This commit is contained in:
@@ -22,16 +22,16 @@ class Template {
|
||||
'tpl_path' => VIEW_PATH, // 模板路径
|
||||
'tpl_suffix' => '.html', // 默认模板文件后缀
|
||||
'cache_suffix' => '.php', // 默认模板缓存后缀
|
||||
'tpl_deny_func_list' => 'echo,exit', // 模板引擎禁用函数
|
||||
'tpl_deny_func_list' => 'echo,exit', // 模板引擎禁用函数
|
||||
'tpl_deny_php' => false, // 默认模板引擎是否禁用PHP原生代码
|
||||
'tpl_begin' => '{', // 模板引擎普通标签开始标记
|
||||
'tpl_end' => '}', // 模板引擎普通标签结束标记
|
||||
'strip_space' => false, // 是否去除模板文件里面的html空格与换行
|
||||
'tpl_cache' => true, // 是否开启模板编译缓存,设为false则每次都会重新编译
|
||||
'compile_type' => 'file', // 模板编译类型
|
||||
'strip_space' => false, // 是否去除模板文件里面的html空格与换行
|
||||
'tpl_cache' => true, // 是否开启模板编译缓存,设为false则每次都会重新编译
|
||||
'compile_type' => 'file', // 模板编译类型
|
||||
'cache_path' => CACHE_PATH, // 模板缓存目录
|
||||
'cache_prefix' => '', // 模板缓存前缀标识,可以动态改变
|
||||
'cache_time' => 0, // 模板缓存有效期 0 为永久,(以数字为值,单位:秒)
|
||||
'cache_time' => 0, // 模板缓存有效期 0 为永久,(以数字为值,单位:秒)
|
||||
'layout_item' => '{__CONTENT__}', // 布局模板的内容替换标识
|
||||
'taglib_begin' => '<', // 标签库标签开始标记
|
||||
'taglib_end' => '>', // 标签库标签结束标记
|
||||
@@ -39,6 +39,7 @@ class Template {
|
||||
'taglib_build_in' => 'cx', // 内置标签库名称(标签使用不必指定标签库名称),以逗号分隔 注意解析顺序
|
||||
'taglib_pre_load' => '', // 需要额外加载的标签库(须指定标签库名称),多个以逗号分隔
|
||||
'display_cache' => false, // 模板渲染缓存
|
||||
'tpl_replace_string' => [],
|
||||
];
|
||||
|
||||
private $literal = [];
|
||||
@@ -210,6 +211,9 @@ class Template {
|
||||
}
|
||||
// 优化生成的php代码
|
||||
$content = str_replace('?><?php','',$content);
|
||||
// 模板过滤输出
|
||||
$replace = $this->config['tpl_replace_string'];
|
||||
$content = str_replace(array_keys($replace),array_values($replace),$content);
|
||||
// 编译存储
|
||||
$this->storage->write($cacheFile,$content);
|
||||
return ;
|
||||
@@ -453,6 +457,7 @@ class Template {
|
||||
$end = $this->config['taglib_end'];
|
||||
$className = '\\think\\template\\taglib\\'.strtolower($tagLib);
|
||||
$tLib = new $className($this);
|
||||
//$that = $this;
|
||||
foreach ($tLib->getTags() as $name=>$val){
|
||||
$tags = [$name];
|
||||
if(isset($val['alias'])) {// 别名设置
|
||||
@@ -470,14 +475,14 @@ class Template {
|
||||
$n1 = empty($val['attr'])?'(\s*?)':'\s([^'.$end.']*)';
|
||||
if (!$closeTag){
|
||||
$patterns = '/'.$begin.$parseTag.$n1.'\/(\s*?)'.$end.'/is';
|
||||
$content = preg_replace_callback($patterns, function($matches){
|
||||
return $this->parseXmlTag($tLib, $tagLib, $tag, $matches[0], $matches[1]);
|
||||
$content = preg_replace_callback($patterns, function($matches) use($tLib,$tagLib,$tag){
|
||||
return $this->parseXmlTag($tLib, $tagLib, $tag, $matches[1], $matches[2]);
|
||||
}, $content);
|
||||
}else{
|
||||
$patterns = '/'.$begin.$parseTag.$n1.$end.'(.*?)'.$begin.'\/'.$parseTag.'(\s*?)'.$end.'/is';
|
||||
for($i=0;$i<$level;$i++){
|
||||
$content = preg_replace_callback($patterns, function($matches){
|
||||
return $this->parseXmlTag($tLib, $tagLib, $tag, $matches[0], $matches[1]);
|
||||
$content = preg_replace_callback($patterns, function($matches) use($tLib,$tagLib,$tag){
|
||||
return $this->parseXmlTag($tLib, $tagLib, $tag, $matches[1], $matches[2]);
|
||||
}, $content);
|
||||
}
|
||||
}
|
||||
@@ -504,7 +509,6 @@ class Template {
|
||||
$parse = '_'.$tag;
|
||||
$content = trim($content);
|
||||
$tags = $tLib->parseXmlAttr($attr,$tag);
|
||||
$tLib->tpl = $this;
|
||||
return $tLib->$parse($tags,$content);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user