From f80521923d35d15dfd2f0ea24359a08a02638845 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Mon, 13 Jun 2011 18:02:40 +0200 Subject: [PATCH] Add {{ if a==b }} and {{ if a!=b }} to templates --- include/template_processor.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/include/template_processor.php b/include/template_processor.php index 3dc249c403..a2c24b00bc 100644 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -41,9 +41,24 @@ * IF node * * {{ if <$var> }}...{{ endif }} + * {{ if <$var>== }}...{{ endif }} + * {{ if <$var>!= }}...{{ endif }} */ private function _replcb_if($args){ - $val = $this->_get_var($args[2]); + + if (strpos($args[2],"==")>0){ + list($a,$b) = array_map("trim",explode("==",$args[2])); + $a = $this->_get_var($a); + if ($b[0]=="$") $b = $this->_get_var($b); + $val = ($a == $b); + } else if (strpos($args[2],"!=")>0){ + list($a,$b) = explode("!=",$args[2]); + $a = $this->_get_var($a); + if ($b[0]=="$") $b = $this->_get_var($b); + $val = ($a != $b); + } else { + $val = $this->_get_var($args[2]); + } return ($val?$args[3]:""); }