From 20212bd8359b8c9898ba60223e684543e85e098a Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Fri, 27 May 2016 15:37:02 +0800 Subject: [PATCH] src/JsRender/NodeToJs.vala --- src/JsRender/NodeToJs.vala | 39 +++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/JsRender/NodeToJs.vala b/src/JsRender/NodeToJs.vala index 77e33050d..92d037447 100644 --- a/src/JsRender/NodeToJs.vala +++ b/src/JsRender/NodeToJs.vala @@ -4,6 +4,13 @@ * * 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. + * + * + * */ @@ -50,9 +57,12 @@ public class JsRender.NodeToJs : Object { this.out_props = new Gee.HashMap(); this.out_listeners = new Gee.HashMap(); + + this.out_nodeprops = new Gee.HashMap() ; this.out_children = new Gee.ArrayList (); - this.out_props_array = new Gee.HashMap>() ; + + this.out_props_array = new Gee.HashMap>(); // filled in by 'checkChildren' this.out_props_array_plain = new Gee.HashMap>() ; @@ -269,12 +279,26 @@ public class JsRender.NodeToJs : Object { } - - + /** + * Line endings + * if we end with a ',' + * + */ + + char last_line_end = 0; + /** + * add a line - note we will end up with an extra line break + * at beginning of nodes doing this.. - public void addLine(string str= "") + * @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 += "/*%d(%d-%d)*/ ".printf(this.cur_line -1, this.node.line_start,this.node.line_end) + str + "\n"; @@ -298,7 +322,12 @@ public class JsRender.NodeToJs : Object { 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 () { -- 2.39.2