src/JsRender/Roo.vala
authorAlan Knowles <alan@roojs.com>
Fri, 19 Jun 2015 06:16:39 +0000 (14:16 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 19 Jun 2015 06:16:39 +0000 (14:16 +0800)
src/JsRender/Roo.vala

index 596237b..5a028ff 100644 (file)
@@ -513,6 +513,43 @@ namespace JsRender {
             */
               
         }
+        
+        /**
+                * 
+                * munge JSON tree into Javascript code.
+                *
+                * NOTE - needs a deep copy of original tree, before starting..
+                *     - so that it does not modify current..
+                * 
+                * FIXME: + or / prefixes to properties hide it from renderer.
+                * FIXME: '*props' - not supported by this.. ?? - upto rendering code..
+                * FIXME: needs to understand what properties might be translatable (eg. double quotes)
+                * 
+                * @arg {object} obj the object or array to munge..
+                * @arg {boolean} isListener - is the array being sent a listener..
+                * @arg {string} pad - the padding to indent with. 
+                */
+               
+               public string mungeToStringWrap(string pad, string prefix, string suffix)
+               {
+                       if (this.tree == null) {
+                               return "";
+                       }
+                       var x = new NodeToJs(this.tree, this.doubleStringProps, pad, null);
+                       x.cur_line = prefix.split("\n").length;
+                       
+                       var ret = x.munge();
+                       //var nret = x.ret;
+                       
+                       // output both files.. so we can diff them...
+                       //this.writeFile("/tmp/old.js", ret);
+                       //this.writeFile("/tmp/new.js", nret);                  
+                       return prefix +  ret + suffix;
+                       
+                   
+               }
+        
+        
        
         public string outputHeader()
         {