Permalink
Browse files

Code: Misc. fixes for hbs test and srv-cson.

  • Loading branch information...
1 parent ba083e8 commit ee85a04655536d47b0ea64fccb217af7a3d61af2 @am11 am11 committed Jun 23, 2015
@@ -6,10 +6,9 @@ var CSON = require("cson"),
//#region Process
var processCSON2JSON = function (data, sourceFileName, targetFileName, writer) {
- if (data)
- data = CSON.parseSync(data);
+ data = CSON.parseCSONString(data);
- if (!data) {
+ if (typeof data === 'Error') {
var error = "CSON: Invalid CSON content found";
writer.write(JSON.stringify({
@@ -32,24 +31,15 @@ var processCSON2JSON = function (data, sourceFileName, targetFileName, writer) {
SourceFileName: sourceFileName,
TargetFileName: targetFileName,
Remarks: "Successful!",
- Content: JSON.stringify(data)
+ Content: CSON.createJSONString(data)
}));
writer.end();
};
var processJSON2CSON = function (data, sourceFileName, targetFileName, writer) {
- var success = true;
+ data = CSON.parseJSONString(data);
- data = data.substr(data.indexOf("{"), data.lastIndexOf("}"));
-
- if (data)
- try {
- data = JSON.parse(data);
- } catch (e) {
- success = false;
- }
-
- if (!data || !success) {
+ if (typeof data === 'Error') {
var err = "CSON: Invalid JSON content found";
writer.write(JSON.stringify({
@@ -72,7 +62,7 @@ var processJSON2CSON = function (data, sourceFileName, targetFileName, writer) {
SourceFileName: sourceFileName,
TargetFileName: targetFileName,
Remarks: "Successful!",
- Content: CSON.stringifySync(data)
+ Content: CSON.createCSONString(data)
}));
writer.end();
};
@@ -1,7 +1,5 @@
//#region Imports
var fs = require("fs"),
- path = require("path"),
- xRegex = require("xregexp").XRegExp,
querystring = require('querystring'),
http = require('http');
//#endregion
@@ -1,16 +1,15 @@
-var test = Handlebars.template({
- "1": function (depth0, helpers, partials, data) {
- return " <h2>Hello</h2>\r\n";
- }, "compiler": [6, ">= 2.0.0-beta.1"], "main": function (depth0, helpers, partials, data) {
- var stack1, helper, functionType = "function", helperMissing = helpers.helperMissing, escapeExpression = this.escapeExpression, buffer = "<div>\r\n <h1>"
- + escapeExpression(((helper = (helper = helpers.hello || (depth0 != null ? depth0.hello : depth0)) != null ? helper : helperMissing), (typeof helper === functionType ? helper.call(depth0, { "name": "hello", "hash": {}, "data": data }) : helper)))
- + "</h1>\r\n <div>\r\n <span>"
- + escapeExpression(((helper = (helper = helpers.world || (depth0 != null ? depth0.world : depth0)) != null ? helper : helperMissing), (typeof helper === functionType ? helper.call(depth0, { "name": "world", "hash": {}, "data": data }) : helper)))
- + "</span>\r\n </div>\r\n";
- stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.hello : depth0), { "name": "if", "hash": {}, "fn": this.program(1, data), "inverse": this.noop, "data": data });
- if (stack1 != null) { buffer += stack1; }
- return buffer + " "
- + escapeExpression(((helpers.customHander || (depth0 && depth0.customHander) || helperMissing).call(depth0, (depth0 != null ? depth0.hello : depth0), { "name": "customHander", "hash": {}, "data": data })))
- + "\r\n</div>\r\n";
- }, "useData": true
-});
+var test = Handlebars.template({"1":function(depth0,helpers,partials,data) {
+ return " <h2>Hello</h2>\r\n";
+},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
+ var stack1, helper, alias1=helpers.helperMissing, alias2="function", alias3=this.escapeExpression;
+
+ return "<div>\r\n <h1>"
+ + alias3(((helper = (helper = helpers.hello || (depth0 != null ? depth0.hello : depth0)) != null ? helper : alias1),(typeof helper === alias2 ? helper.call(depth0,{"name":"hello","hash":{},"data":data}) : helper)))
+ + "</h1>\r\n <div>\r\n <span>"
+ + alias3(((helper = (helper = helpers.world || (depth0 != null ? depth0.world : depth0)) != null ? helper : alias1),(typeof helper === alias2 ? helper.call(depth0,{"name":"world","hash":{},"data":data}) : helper)))
+ + "</span>\r\n </div>\r\n"
+ + ((stack1 = helpers['if'].call(depth0,(depth0 != null ? depth0.hello : depth0),{"name":"if","hash":{},"fn":this.program(1, data, 0),"inverse":this.noop,"data":data})) != null ? stack1 : "")
+ + " "
+ + alias3((helpers.customHander || (depth0 && depth0.customHander) || alias1).call(depth0,(depth0 != null ? depth0.hello : depth0),{"name":"customHander","hash":{},"data":data}))
+ + "\r\n</div>\r\n";
+},"useData":true});

0 comments on commit ee85a04

Please sign in to comment.