src/JsRender/Node.vala
[app.Builder.js] / src / JsRender / NodeToJs.vala
index 39de56e..6b8676f 100644 (file)
@@ -184,8 +184,10 @@ public class JsRender.NodeToJs : Object {
                         
                        var k = iter.get();
                        var v = this.out_props.get(k);
-                       
+                       this.node.setLine(this.cur_line, "p",k); //listener
                        this.addLine(this.pad + k + " : " + v + suffix, ',');
+                       
+                       
                }
         
                // listeners..
@@ -199,9 +201,9 @@ public class JsRender.NodeToJs : Object {
                                
                                var k = iter.get();
                                var v = this.out_listeners.get(k);
-                               this.addLine(this.pad + indent_str + k + " : ", '');
                                this.node.setLine(this.cur_line, "l",k); //listener
-                               this.addLine( v,',');
+                               this.addLine(this.pad + indent_str + k + " : " + v , ',');
+                               
                        }
                        
                        this.closeLine();
@@ -220,9 +222,13 @@ public class JsRender.NodeToJs : Object {
                var niter = this.out_nodeprops.map_iterator();
 
                while(niter.next()) {
-                       this.addLine(this.pad + niter.get_key() + " : ", '');
                        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 (iter.get_key() == "xns") {
+                                       this.addLine(this.pad + "'|xns' : '" + addstr + "'", ',');
+
+                               }
                        
                }                        
                // prop arrays...
@@ -230,8 +236,8 @@ public class JsRender.NodeToJs : Object {
                var piter = this.out_props_array.map_iterator();
 
                while(piter.next()) {
-
-                       this.addLine(this.pad + piter.get_key() + " : [", '');
+                       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()) {
@@ -244,13 +250,12 @@ public class JsRender.NodeToJs : Object {
                
                // children..
                if (this.out_children.size > 0) {
-                       this.addLine(this.pad + "items  : [" , '');
+                       this.addLine(this.pad + "items  : [" , 0);
                        var cniter = this.out_children.list_iterator();
                        while (cniter.next()) {
                                suffix = cniter.has_next()  ? "," : "";
-                               this.addMultiLine(this.pad + indent_str +
-                                       this.mungeChildNew(this.pad + indent_str  + indent_str, cniter.get()) + suffix
-                               );
+                               var addstr = this.mungeChildNew(this.pad + indent_str  + indent_str, cniter.get());
+                               this.addLine(this.pad + indent_str + addstr, ',');
                                
                        }
                        this.closeLine();
@@ -259,10 +264,10 @@ public class JsRender.NodeToJs : Object {
                
                this.closeLine();
                if (this.node.props.has_key("* xinclude")) {
-                       this.addLine(spad + "})",'');
+                       this.addLine(spad + "})",0);
         
                } else {
-                       this.addLine( spad + "}", '');
+                       this.addLine( spad + "}", 0);
                }
                
                this.node.sortLines();
@@ -276,7 +281,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 
@@ -289,7 +294,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;
@@ -429,15 +436,7 @@ public class JsRender.NodeToJs : Object {
        {
                string left;
                Regex func_regex ;
-
-               if (this.node.props.has_key("$ xns")) {
-                       this.out_props.set("'|xns'", "'" +  this.node.props.get("$ xns") + "'" );
-                       
-                       //this.els.add("'|xns' : '" + this.node.props.get("$ xns") + "'");
-
-               }
-
-               
                try {
                        func_regex = new Regex("^\\s+|\\s+$");
                } catch (RegexError e) {
@@ -562,6 +561,11 @@ public class JsRender.NodeToJs : Object {
                                        //nstr =  string.joinv("\n", lines);
                                }
                                this.out_props.set(left, nstr);
+                               
+                               
+
+                               
+                               
                                //print("==> " +  str + "\n");
                                //this.els.add(left + " : "+  nstr);
                                continue;