aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-06-13 18:02:40 +0200
committerFabio Comuni <fabrix.xm@gmail.com>2011-06-13 18:02:40 +0200
commitf80521923d35d15dfd2f0ea24359a08a02638845 (patch)
treeef3766c52bc34164845ca5c2ab9495fb25d7cffb /include
parente14d5851a76e73675800787dcbcc7582b4dbd5ed (diff)
downloadvolse-hubzilla-f80521923d35d15dfd2f0ea24359a08a02638845.tar.gz
volse-hubzilla-f80521923d35d15dfd2f0ea24359a08a02638845.tar.bz2
volse-hubzilla-f80521923d35d15dfd2f0ea24359a08a02638845.zip
Add {{ if a==b }} and {{ if a!=b }} to templates
Diffstat (limited to 'include')
-rw-r--r--include/template_processor.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/include/template_processor.php b/include/template_processor.php
index 3dc249c40..a2c24b00b 100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -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]:"");
}