From: Fabrixxm Date: Fri, 10 Aug 2012 08:55:51 +0000 (-0400) Subject: template processor: trim strings in {{ if str!=str }}, add 'debug' tag: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=dbbf5b86a2ebfe862d4d833be41997d8b596f260;p=friendica.git template processor: trim strings in {{ if str!=str }}, add 'debug' tag: {{ debug $var [$var1 [$var2 [...]]] }}{{ enddebug }} is replaced by
var_export($var1)\nvar_export($var2)\n....
--- diff --git a/include/template_processor.php b/include/template_processor.php index 46252c355f..4088ddab60 100644 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -63,7 +63,7 @@ if ($b[0]=="$") $b = $this->_get_var($b); $val = ($a == $b); } else if (strpos($args[2],"!=")>0){ - list($a,$b) = explode("!=",$args[2]); + 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); @@ -133,6 +133,26 @@ return $ret; } + + /** + * DEBUG node + * + * {{ debug $var [$var [$var [...]]] }}{{ enddebug }} + * + * replace node with
var_dump($var, $var, ...);
+ */ + private function _replcb_debug($args){ + $vars = array_map('trim', explode(" ",$args[2])); + $vars[] = $args[1]; + + $ret = "
";
+			foreach ($vars as $var){
+				$ret .= htmlspecialchars(var_export( $this->_get_var($var), true ));
+				$ret .= "\n";
+			}
+			$ret .= "
"; + return $ret; + } private function _replcb_node($m) { $node = $this->nodes[$m[1]];