src/JsRender/NodeToGtk.vala
[app.Builder.js] / src / JsRender / NodeToJs.vala
index 4138875..6a6b1ca 100644 (file)
@@ -14,10 +14,12 @@ public class JsRender.NodeToJs : Object {
        static uint indent = 1;
        static string indent_str = " ";
        
+       
+       
        Node node;
        Gee.ArrayList<string>  doubleStringProps;  // need to think if this is a good idea like this
        string pad;
-       
+       public JsRender renderer;
          
        Gee.HashMap<string,string> out_props;
        Gee.HashMap<string,string> out_listeners;       
@@ -52,6 +54,9 @@ public class JsRender.NodeToJs : Object {
                
                
                this.cur_line = parent == null ? 0 : parent.cur_line  ; //-1 as we usuall concat onto the existin gline?
+               if (parent != null) {
+                       this.renderer = parent.renderer;
+               }
                this.ret = "";
                this.top = parent == null ? this : parent.top;
                // reset the maps...
@@ -70,7 +75,6 @@ public class JsRender.NodeToJs : Object {
        {
                //return this.mungeToString(this.node);
 
-               this.node.line_start = this.cur_line;
                
                this.checkChildren();
                this.readProps();
@@ -268,18 +272,18 @@ public class JsRender.NodeToJs : Object {
        public void addLine(string str= "")
        {
                this.cur_line ++;
-               //this.ret += str+ "\n";
-               this.ret +=  "/*%d(%d-%d)*/ ".printf(this.cur_line -1, this.node.line_start,this.node.line_end) + str + "\n";
+               this.ret += str+ "\n";
+               //this.ret +=  "/*%d(%d-%d)*/ ".printf(this.cur_line -1, this.node.line_start,this.node.line_end) + str + "\n";
                
                
        }
        
        public void addMultiLine(string str= "")
        {
-               var l = cur_line;
+
+               //this.ret +=   "/*%d(%d-%d)*/ ".printf(this.cur_line, this.node.line_start,this.node.line_end)+ str + "\n";
+               this.ret +=   str + "\n";
                this.cur_line += str.split("\n").length;
-               //this.ret +=   "/*%d(%d-%d)*/ ".printf(l, this.node.line_start,this.node.line_end)+ str + "\n";
-               //this.ret +=   str + "\n";
        }
  
        public string mungeChildNew(string pad ,  Node cnode )
@@ -428,7 +432,7 @@ public class JsRender.NodeToJs : Object {
                        //return a < b ? -1 : 1;
                });
                
-               
+               var has_cms = this.node.has("cms-id");
                
                for (var i = 0; i< keys.size; i++) {
                        var key = this.node.get_key(keys.get(i));
@@ -457,10 +461,30 @@ public class JsRender.NodeToJs : Object {
                        if (kflag == ".") { // |. or . -- do not output..
                                continue;
                        }
-                        if (kflag == "*") {
+                       if (kflag == "*") {
                                // ignore '* prop'; ??? 
                                continue;
-                        }
+                       }
+                       
+                       // handle cms-id // html
+                       if (has_cms && k == "cms-id") {
+                               continue; // ignore it...
+                       }
+                       // html must not be a dynamic property...
+                       // note - we do not translate this either...
+                       if (has_cms && k == "html" && kflag != "$") {
+                                
+
+                               this.out_props.set("html", "Pman.Cms.content(" + 
+                                       this.node.quoteString(this.renderer.name + "::" + this.node.get("cms-id")) +
+                                        ", " +
+                                       this.node.quoteString(v) +
+                                        ")");
+                                        
+                               continue;        
+                       }
+                       
+                       
                                
                        
                        if (Lang.isKeyword(leftv) || Lang.isBuiltin(leftv)) {