src/JsRender/NodeToJs.vala
[app.Builder.js] / src / JsRender / NodeToJs.vala
index be490a3..9d93411 100644 (file)
@@ -186,6 +186,8 @@ public class JsRender.NodeToJs : Object {
                        var v = this.out_props.get(k);
                        this.node.setLine(this.cur_line, "p",k); //listener
                        this.addLine(this.pad + k + " : " + v + suffix, ',');
+                       this.node.setLine(this.cur_line, "e", "");
+                       
                }
         
                // listeners..
@@ -201,7 +203,7 @@ public class JsRender.NodeToJs : Object {
                                var v = this.out_listeners.get(k);
                                this.node.setLine(this.cur_line, "l",k); //listener
                                this.addLine(this.pad + indent_str + k + " : " + v , ',');
-                               
+                               this.node.setLine(this.cur_line, "e", "");
                        }
                        
                        this.closeLine();
@@ -211,7 +213,7 @@ public class JsRender.NodeToJs : Object {
                
                //------- at this point it is the end of the code relating directly to the object..
                
-               this.node.line_end = this.cur_line;
+               
                
                
                
@@ -220,23 +222,28 @@ public class JsRender.NodeToJs : Object {
                var niter = this.out_nodeprops.map_iterator();
 
                while(niter.next()) {
-                       this.addLine(this.pad + niter.get_key() + " : ", 0);
                        var addstr = this.mungeChildNew(this.pad + indent_str, niter.get_value());
-                       this.addLine(addstr,',') ;
-                       
+                       this.node.setLine(this.cur_line, "p",niter.get_key());
+                       this.addLine(this.pad + niter.get_key() + " : " + addstr, ',');
+                       if (niter.get_key() == "xns") {
+                               this.addLine(this.pad + "'|xns' : '" + addstr + "'", ',');
+
+                       }
+                       this.node.setLine(this.cur_line, "e", "");
                }                        
                // prop arrays...
                
                var piter = this.out_props_array.map_iterator();
 
                while(piter.next()) {
-
+                       this.node.setLine(this.cur_line, "p",niter.get_key());
                        this.addLine(this.pad + piter.get_key() + " : [", 0);
                        
                        var pliter = piter.get_value().list_iterator();
                        while (pliter.next()) {
                                var addstr = this.mungeChildNew(this.pad + indent_str  + indent_str, pliter.get());
                                this.addLine(this.pad + indent_str + addstr, ',');
+                               this.node.setLine(this.cur_line, "e", "");
                        }
                        this.closeLine();
                        this.addLine(this.pad + "]" , ',');                     
@@ -265,6 +272,9 @@ public class JsRender.NodeToJs : Object {
                }
                
                this.node.sortLines();
+               
+               this.node.line_end = this.cur_line;
+               
                return this.ret;
        
        }
@@ -275,7 +285,7 @@ public class JsRender.NodeToJs : Object {
        *
        */
 
-       char last_line_end = 0
+       char last_line_end = '!'
        
        /**
        * add a line - note we will end up with an extra line break 
@@ -288,7 +298,9 @@ public class JsRender.NodeToJs : Object {
        */
        public void addLine(string str, char line_end)
        {
-               this.ret += (this.last_line_end == 0 ? "" : this.last_line_end.to_string()) + "\n"; 
+               if (this.last_line_end != '!') {
+                       this.ret += (this.last_line_end == 0 ? "" : this.last_line_end.to_string()) + "\n"; 
+               }
                this.last_line_end = line_end;
                this.cur_line += str.split("\n").length;
                this.ret += str;
@@ -554,10 +566,7 @@ public class JsRender.NodeToJs : Object {
                                }
                                this.out_props.set(left, nstr);
                                
-                               if (left == "xns") {
-               
-                                       this.out_props.set("'|xns'", "'" +  nstr + "'" );
-                               }
+