JsTemplate.php
[Pman.Core] / JsTemplate.php
index 5cb87a9..54667b7 100644 (file)
@@ -94,7 +94,7 @@ class Pman_Core_JsTemplate extends Pman {
         
         
         $contents = file_get_contents($fn);
-        $ar = preg_split('/(\{[^\}]+})/', $contents, -1, PREG_SPLIT_DELIM_CAPTURE);
+        $ar = preg_split('/(\{[^\\n}]+})/', $contents, -1, PREG_SPLIT_DELIM_CAPTURE);
         
         
         
@@ -108,12 +108,12 @@ class Pman_Core_JsTemplate extends Pman {
         $funcs = array();
         // do not allow nested functions..?
         $fstart = -1;
-        $indent = 1;
+        $indent = 2;
         $inscript = false;
         $ret = &$out;
         foreach($ar as $item) {
             $in = str_repeat("    ", $indent);
-            
+            $indent  = max($indent , 1);
             //var_Dump(substr($item,-3,2));
             switch(true) {
                 case (!strlen($item)):
@@ -126,12 +126,8 @@ class Pman_Core_JsTemplate extends Pman {
                 case ($inscript && ($item == '{end:}')):
                     $inscript = false;
                     continue;
-                
-                
-                case ($inscript):
-                     $ret[] = $item;
-                     continue;
-                    
+                 
+             
                 case ($item[0] != '{'):
                     if (!strlen(trim($item))) {
                         continue;
@@ -144,6 +140,9 @@ class Pman_Core_JsTemplate extends Pman {
                     $inscript = true;
                     continue;
                 
+                case ($item[1] == '!'):
+                    $ret[] = $in . substr($item,2,-1) .';';
+                    continue;
                 
                 
                 case (substr($item,1,3) == 'if('):
@@ -181,6 +180,10 @@ class Pman_Core_JsTemplate extends Pman {
                         $ret[] = $in . "ret += ".  substr($item,1,-3) . ';';
                         continue;
                     }
+                    if (substr($item,-3,2) == ':b') {
+                        $ret[] = $in . "ret += Roo.util.Format.htmlEncode(".  substr($item,1,-3).').split("\n").join("<br/>\n");';
+                        continue;
+                    }
                     $ret[] = $in . "ret += Roo.util.Format.htmlEncode(".  substr($item,1,-1).');';
                     continue;