*
* 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.
+ *
+ *
+ *
*/
Node node;
Gee.ArrayList<string> doubleStringProps; // need to think if this is a good idea like this
string pad;
- JsRender jsrender;
+ public JsRender renderer;
Gee.HashMap<string,string> out_props;
Gee.HashMap<string,string> out_listeners;
//this.ar_props = new Gee.HashMap<string,string>();
+
+ // this is the bit that causes issues - we have to output as we go, otherwise we
+ // can not work out which line is which...
+
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>>() ;
this.cur_line = parent == null ? 0 : parent.cur_line ; //-1 as we usuall concat onto the existin gline?
if (parent != null) {
- this.jsrender = parent.jsrender;
+ this.renderer = parent.renderer;
}
this.ret = "";
this.top = parent == null ? this : parent.top;
}
-
-
-
+ /**
+ * 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.ret += (this.line_end == 0 ? "" : this.last_line_end) + "\n";
this.cur_line ++;
- this.ret += str+ "\n";
+ this.ret += str ;
//this.ret += "/*%d(%d-%d)*/ ".printf(this.cur_line -1, this.node.line_start,this.node.line_end) + str + "\n";
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 ()
{
//var prop = pl['*prop'] + '';
//delete pl['*prop'];
var prop = pl.get("* prop");
- print("got prop "+ prop + "\n");
+ //print("got prop "+ prop + "\n");
// name ends in [];
if (! Regex.match_simple("\\[\\]$", prop)) {
var sprop = prop.replace("[]", "");
- print("sprop is : " + sprop + "\n");
+ //print("sprop is : " + sprop + "\n");
// it's an array type..
//var old = "";
for (var i = 0; i< keys.size; i++) {
var key = this.node.get_key(keys.get(i));
- print("ADD KEY %s\n", key);
+ //("ADD KEY %s\n", key);
string k;
string ktype;
string kflag;
this.out_props.set("html", "Pman.Cms.content(" +
- this.node.quoteString(this.jsrender.name + "::" + this.node.get("cms-id")) +
+ this.node.quoteString(this.renderer.name + "::" + this.node.get("cms-id")) +
", " +
this.node.quoteString(v) +
")");
// "']"
//);
this.out_props.set(left, "_this._strings['" +
- GLib.Checksum.compute_for_string (ChecksumType.MD5, v) +
+ GLib.Checksum.compute_for_string (ChecksumType.MD5, v.strip()) +
"']" + com);
continue;
}