From f1f48f4a2ccc9788a0de98730eaa6fe749b95ac7 Mon Sep 17 00:00:00 2001 From: top_nuomi <1130395124@qq.com> Date: Sat, 31 Aug 2019 15:15:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0if/else=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=AF=94=E8=BE=83=E7=AC=A6=E6=94=AF=E6=8C=81=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/template/driver/engine/Engine.php | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/framework/library/template/driver/engine/Engine.php b/framework/library/template/driver/engine/Engine.php index dc0736e..ed02f8d 100644 --- a/framework/library/template/driver/engine/Engine.php +++ b/framework/library/template/driver/engine/Engine.php @@ -396,9 +396,10 @@ class Engine */ private function _if($tag, $content) { + $tag['condition'] = $this->_parseCondition($tag['condition']); $parse = ''; $parse .= $content; - $parse .= ''; + $parse .= ''; return $parse; } @@ -410,6 +411,7 @@ class Engine private function _else($tag) { if (isset($tag['condition'])) { + $tag['condition'] = $this->_parseCondition($tag['condition']); $parse = ''; } else { $parse = ''; @@ -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