]> git.mxchange.org Git - friendica.git/commitdiff
template processor: trim strings in {{ if str!=str }}, add 'debug' tag:
authorFabrixxm <fabrix.xm@gmail.com>
Fri, 10 Aug 2012 08:55:51 +0000 (04:55 -0400)
committerFabrixxm <fabrix.xm@gmail.com>
Fri, 10 Aug 2012 08:55:51 +0000 (04:55 -0400)
    {{ debug $var [$var1 [$var2 [...]]] }}{{ enddebug }}

is replaced by

    <pre>var_export($var1)\nvar_export($var2)\n....</pre>

include/template_processor.php

index 46252c355f54b5509ab34a8f2e2fec7925fbaae2..4088ddab60840864c6b111c81c81615b1371cc94 100644 (file)
@@ -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);
                        return $ret;
                        
                }
+               
+               /**
+                * DEBUG node
+                * 
+                * {{ debug $var [$var [$var [...]]] }}{{ enddebug }}
+                * 
+                * replace node with <pre>var_dump($var, $var, ...);</pre>
+                */
+               private function _replcb_debug($args){
+                       $vars = array_map('trim', explode(" ",$args[2]));
+                       $vars[] = $args[1];
+
+                       $ret = "<pre>";
+                       foreach ($vars as $var){
+                               $ret .= htmlspecialchars(var_export( $this->_get_var($var), true ));
+                               $ret .= "\n";
+                       }
+                       $ret .= "</pre>";
+                       return $ret;
+               }
 
                private function _replcb_node($m) {
                        $node = $this->nodes[$m[1]];