mirror of
https://github.com/friendica/friendica
synced 2024-12-23 12:40:17 +00:00
Add {{ if a==b }} and {{ if a!=b }} to templates
This commit is contained in:
parent
e14d5851a7
commit
f80521923d
1 changed files with 16 additions and 1 deletions
|
@ -41,9 +41,24 @@
|
|||
* IF node
|
||||
*
|
||||
* {{ if <$var> }}...{{ endif }}
|
||||
* {{ if <$var>==<val|$var> }}...{{ endif }}
|
||||
* {{ if <$var>!=<val|$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]:"");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue