mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-09 11:32:48 +08:00
feat: 增加var标签
This commit is contained in:
@@ -45,6 +45,7 @@ class Cx extends Taglib
|
||||
'notdefined' => ['attr' => 'name'],
|
||||
'load' => ['attr' => 'file,href,type,value,basepath', 'close' => 0, 'alias' => ['import,css,js', 'type']],
|
||||
'assign' => ['attr' => 'name,value', 'close' => 0],
|
||||
'var' => ['attr' => 'name,value', 'close' => 0],
|
||||
'define' => ['attr' => 'name,value', 'close' => 0],
|
||||
'for' => ['attr' => 'start,end,name,comparison,step'],
|
||||
'url' => ['attr' => 'link,vars,suffix,domain', 'close' => 0, 'expression' => true],
|
||||
@@ -577,6 +578,33 @@ class Cx extends Taglib
|
||||
return $parseStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果变量在当前上下文不存在则设置,否则不设置
|
||||
*
|
||||
* @param array $tag
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
public function tagVar(array $tag, string $content): string
|
||||
{
|
||||
$name = $this->autoBuildVar($tag['name']);
|
||||
|
||||
if(!isset($tag['value'])) {
|
||||
$value = 'null';
|
||||
}else{
|
||||
$flag = substr($tag['value'], 0, 1);
|
||||
|
||||
if ('$' == $flag || ':' == $flag) {
|
||||
$value = $this->autoBuildVar($tag['value']);
|
||||
} else {
|
||||
$value = '\'' . $tag['value'] . '\'';
|
||||
}
|
||||
}
|
||||
|
||||
$parseStr = '<?php if(!isset('.$name.')) { ' . $name . ' = ' . $value . ' ;} ?>';
|
||||
return $parseStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* define标签解析
|
||||
* 在模板中定义常量 支持变量赋值
|
||||
|
||||
Reference in New Issue
Block a user