*
* usage : x = (new JsRender.NodeToJs(node)).munge();
*
+ *
+ * We are changing this to output as we go.
+ * However... since line-endings on properties have ',' (not ;) like vala.
+ * we have to be a bit smarter about how to output.
+ *
+ *
+ *
*/
this.out_props = new Gee.HashMap<string,string>();
this.out_listeners = new Gee.HashMap<string,string>();
+
+
this.out_nodeprops = new Gee.HashMap<string,Node>() ;
this.out_children = new Gee.ArrayList<Node> ();
- this.out_props_array = new Gee.HashMap<string,Gee.ArrayList<Node>>() ;
+
+ this.out_props_array = new Gee.HashMap<string,Gee.ArrayList<Node>>(); // filled in by 'checkChildren'
this.out_props_array_plain = new Gee.HashMap<string,Gee.ArrayList<string>>() ;
var spad = this.pad.substring(0, this.pad.length-indent);
if (this.node.props.has_key("* xinclude")) {
- this.addLine("Roo.apply(" + this.node.props.get("* xinclude") + "._tree(), {");
+ this.addLine("Roo.apply(" + this.node.props.get("* xinclude") + "._tree(), {",0 );
} else {
- this.addLine("{");
+ this.addLine("{", 0);
}
var suffix = "";
// output the items...
// work out remaining items...
- var total_nodes = this.out_props.size +
- this.out_props_array_plain.size +
- (this.out_listeners.size > 0 ? 1 : 0) +
- this.out_nodeprops.size +
- this.out_props_array.size +
- (this.out_children.size > 0 ? 1 : 0);
-
-
+
// plain properties.
var iter = this.orderedPropKeys().list_iterator();
while(iter.next()) {
- total_nodes--;
- suffix = total_nodes > 0 ? "," : "";
+
+
var k = iter.get();
var v = this.out_props.get(k);
- this.addMultiLine(this.pad + k + " : " + v + suffix);
+ this.addLine(this.pad + k + " : " + v + suffix, ',');
}
// listeners..
if (this.out_listeners.size > 0 ) {
- total_nodes--;
- this.addLine(this.pad + "listeners : {");
+
+ this.addLine(this.pad + "listeners : {", 0);
iter = this.orderedListenerKeys().list_iterator();
- var sz = this.out_listeners.size;
while(iter.next()) {
- sz--;
- suffix = sz > 0 ? "," : "";
+
var k = iter.get();
var v = this.out_listeners.get(k);
- this.addMultiLine(this.pad + indent_str + k + " : " + v + suffix);
+ this.addLine(this.pad + indent_str + k + " : ", '');
+ this.node.setLine(this.cur_line, "l",k);
+ this.addLine( v,',');
}
- suffix = total_nodes > 0 ? "," : "";
- this.addLine(this.pad + "}" + suffix);
+
+ this.closeLine();
+ this.addLine(this.pad + "}" ,',');
}
}
-
-
-
+ /**
+ * Line endings
+ * if we end with a ','
+ *
+ */
+
+ char last_line_end = 0;
- public void addLine(string str= "")
+ /**
+ * add a line - note we will end up with an extra line break
+ * at beginning of nodes doing this..
+ *
+ * @param str = text to add..
+ * @param line_end = 0 (just add a line break)
+ * line_end = ',' and ","
+ *
+ */
+ public void addLine(string str, char line_end)
{
- this.cur_line ++;
- this.ret += str+ "\n";
+ 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;
+
+
//this.ret += "/*%d(%d-%d)*/ ".printf(this.cur_line -1, this.node.line_start,this.node.line_end) + str + "\n";
}
+ public void closeLine() // send this before '}' or ']' to block output of ',' ...
+ {
+ this.last_line_end = 0;
+ }
- public void addMultiLine(string str= "")
+/* public void addMultiLine(str= "")
{
-
- //this.ret += "/*%d(%d-%d)*/ ".printf(this.cur_line, this.node.line_start,this.node.line_end)+ str + "\n";
+
+ //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;
}
-
+ */
public string mungeChildNew(string pad , Node cnode )
{
var x = new NodeToJs(cnode, this.doubleStringProps, pad, this);
return x.ret;
}
-
+ /**
+ * loop through items[] array see if any of the children have '* prop'
+ * -- which means they are a property of this node.
+ * -- ADD TO : this.opt_props_array
+ *
+ */
public void checkChildren ()
{