增加if/else条件比较符支持,避免冲突
This commit is contained in:
parent
a056c9a27c
commit
f1f48f4a2c
|
@ -396,9 +396,10 @@ class Engine
|
|||
*/
|
||||
private function _if($tag, $content)
|
||||
{
|
||||
$tag['condition'] = $this->_parseCondition($tag['condition']);
|
||||
$parse = '<?php if (' . $tag['condition'] . '): ?>';
|
||||
$parse .= $content;
|
||||
$parse .= '<?php echo ' . $tag['condition'] . '; endif; ?>';
|
||||
$parse .= '<?php endif; ?>';
|
||||
return $parse;
|
||||
}
|
||||
|
||||
|
@ -410,6 +411,7 @@ class Engine
|
|||
private function _else($tag)
|
||||
{
|
||||
if (isset($tag['condition'])) {
|
||||
$tag['condition'] = $this->_parseCondition($tag['condition']);
|
||||
$parse = '<?php elseif (' . $tag['condition'] . '): ?>';
|
||||
} else {
|
||||
$parse = '<?php else: ?>';
|
||||
|
@ -417,6 +419,34 @@ class Engine
|
|||
return $parse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理if/else标签的条件比较符
|
||||
* @param $condition
|
||||
* @return mixed
|
||||
*/
|
||||
private function _parseCondition($condition)
|
||||
{
|
||||
return str_ireplace([
|
||||
' eq ',
|
||||
' neq ',
|
||||
' lt ',
|
||||
' elt ',
|
||||
' gt ',
|
||||
' egt ',
|
||||
' heq ',
|
||||
' nheq '
|
||||
], [
|
||||
' == ',
|
||||
' != ',
|
||||
' < ',
|
||||
' <= ',
|
||||
' > ',
|
||||
' >= ',
|
||||
' === ',
|
||||
' !== '
|
||||
], $condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* volist标签
|
||||
* @param $tag
|
||||
|
|
Loading…
Reference in New Issue