JsTemplate.php
authorAlan Knowles <alan@akbkhome.com>
Thu, 17 Nov 2011 09:44:33 +0000 (17:44 +0800)
committerAlan Knowles <alan@akbkhome.com>
Thu, 17 Nov 2011 09:44:33 +0000 (17:44 +0800)
JsTemplate.php

index 3a86a02..b19c87f 100644 (file)
@@ -95,6 +95,10 @@ class Pman_Core_JsTemplate extends Pman {
         
         $contents = file_get_contents($fn);
         $ar = preg_split('/(\{[^\}]+})/', $contents, -1, PREG_SPLIT_DELIM_CAPTURE);
+        
+        
+        
+        
         //echo '<PRE>' . htmlspecialchars(print_r($ar,true));
         
         $out= array();
@@ -115,6 +119,10 @@ class Pman_Core_JsTemplate extends Pman {
                 case (!strlen($item)):
                     continue;
                 
+                if ($inscript && ($item != '{end:}') {
+                    $ret[] = $item;
+                }
+                
                 case ($item[0] != '{'):
                     if (!strlen(trim($item))) {
                         continue;
@@ -122,6 +130,13 @@ class Pman_Core_JsTemplate extends Pman {
                     $ret[] = $in . "ret += ". json_encode($item) . ";";
                     continue;
                 
+                
+                case (substr($item,1,6) == 'script:'): 
+                    $inscript = true;
+                    continue;
+                
+                
+                
                 case (substr($item,1,3) == 'if('):
                     $ret[] = $in . substr($item,1,-1) . ' {';
                     $indent++;