Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

0.3.18

  • Loading branch information...
commit 48a04bdccebe6a0aaf96ea3a971d45daf2e34461 1 parent 5ee2d66
@jeffsu authored
View
5 CHANGELOG
@@ -1,3 +1,8 @@
+0.3.18
+ * COMMAND: updaters should be using targetDir instead of outDir
+ * JSML: fixed empty space problem
+ * JSML: support for self-closing tags: area, base, basefont, br, hr, input, img, link, meta
+
0.3.17
* CORE: Adding counter to foreach "foreach (var item:i in items) { }"
* COMMAND: Fixing compile to use targetDir instead of outDir
View
25 dist/browser/js2-full.js
@@ -1242,9 +1242,9 @@ JS2.Class.extend('FileSystem', function(KLASS, OO){
JS2.Class.extend('Updater', function(KLASS, OO){
OO.addMember("initialize",function (fs, inDir, outDir, recursive) {
this.recursive = recursive;
- this.fs = fs;
- this.inDir = this.fs.canonical(inDir);
- this.outDir = this.fs.canonical(outDir);
+ this.fs = fs;
+ this.inDir = this.fs.canonical(inDir);
+ this.targetDir = this.fs.canonical(outDir);
this.verbose = true;
});
@@ -1261,14 +1261,14 @@ JS2.Class.extend('Updater', function(KLASS, OO){
for(var _i1=0,_c1=subs,_l1=_c1.length,sub;(sub=_c1[_i1])||(_i1<_l1);_i1++){
var path = dir + '/' + sub;
if (this.fs.isDirectory(path)) {
- this.fs.mkdir(path.replace(this.inDir, this.outDir));
+ this.fs.mkdir(path.replace(this.inDir, this.targetDir));
this.matchDirs(path);
}
}
});
OO.addMember("tryUpdate",function (file, force, funct) {
- var outFile = file.replace(this.inDir, this.outDir).replace(/\.js2$/, '.js');
+ var outFile = file.replace(this.inDir, this.targetDir).replace(/\.js2$/, '.js');
var dir = this.fs.dirname(file);
if (! this.fs.isDirectory(dir)) this.fs.mkpath(dir);
@@ -1518,6 +1518,8 @@ JS2.Class.extend('JSML', function(KLASS, OO){
});
OO.addMember("processLine",function (line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -1555,6 +1557,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
+ OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
OO.addMember("initialize",function (line) {
this.children = [];
@@ -1614,6 +1617,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
});
OO.addMember("flatten",function () {
@@ -1629,8 +1638,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
15 dist/browser/js2.js
@@ -299,6 +299,8 @@ JS2.Array.prototype.any = function() {
});
OO.addMember("processLine",function (line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -336,6 +338,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
+ OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
OO.addMember("initialize",function (line) {
this.children = [];
@@ -395,6 +398,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
});
OO.addMember("flatten",function () {
@@ -410,8 +419,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
7 dist/gem/CHANGELOG
@@ -1,3 +1,10 @@
+0.3.19
+ * JSML: fixed empty space problem
+ * JSML: support for self-closing tags: area, base, basefont, br, hr, input, img, link, meta
+
+0.3.18
+ * COMMAND: updaters should be using targetDir instead of outDir
+
0.3.17
* CORE: Adding counter to foreach "foreach (var item:i in items) { }"
* COMMAND: Fixing compile to use targetDir instead of outDir
View
25 dist/gem/lib/js2/js2.js
@@ -1238,9 +1238,9 @@ JS2.Class.extend('FileSystem', function(KLASS, OO){
JS2.Class.extend('Updater', function(KLASS, OO){
OO.addMember("initialize",function (fs, inDir, outDir, recursive) {
this.recursive = recursive;
- this.fs = fs;
- this.inDir = this.fs.canonical(inDir);
- this.outDir = this.fs.canonical(outDir);
+ this.fs = fs;
+ this.inDir = this.fs.canonical(inDir);
+ this.targetDir = this.fs.canonical(outDir);
this.verbose = true;
});
@@ -1257,14 +1257,14 @@ JS2.Class.extend('Updater', function(KLASS, OO){
for(var _i1=0,_c1=subs,_l1=_c1.length,sub;(sub=_c1[_i1])||(_i1<_l1);_i1++){
var path = dir + '/' + sub;
if (this.fs.isDirectory(path)) {
- this.fs.mkdir(path.replace(this.inDir, this.outDir));
+ this.fs.mkdir(path.replace(this.inDir, this.targetDir));
this.matchDirs(path);
}
}
});
OO.addMember("tryUpdate",function (file, force, funct) {
- var outFile = file.replace(this.inDir, this.outDir).replace(/\.js2$/, '.js');
+ var outFile = file.replace(this.inDir, this.targetDir).replace(/\.js2$/, '.js');
var dir = this.fs.dirname(file);
if (! this.fs.isDirectory(dir)) this.fs.mkpath(dir);
@@ -1514,6 +1514,8 @@ JS2.Class.extend('JSML', function(KLASS, OO){
});
OO.addMember("processLine",function (line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -1551,6 +1553,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
+ OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
OO.addMember("initialize",function (line) {
this.children = [];
@@ -1610,6 +1613,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
});
OO.addMember("flatten",function () {
@@ -1625,8 +1634,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
7 dist/npm/CHANGELOG
@@ -1,3 +1,10 @@
+0.3.19
+ * JSML: fixed empty space problem
+ * JSML: support for self-closing tags: area, base, basefont, br, hr, input, img, link, meta
+
+0.3.18
+ * COMMAND: updaters should be using targetDir instead of outDir
+
0.3.17
* CORE: Adding counter to foreach "foreach (var item:i in items) { }"
* COMMAND: Fixing compile to use targetDir instead of outDir
View
25 dist/npm/lib/js2.js
@@ -1238,9 +1238,9 @@ JS2.Class.extend('FileSystem', function(KLASS, OO){
JS2.Class.extend('Updater', function(KLASS, OO){
OO.addMember("initialize",function (fs, inDir, outDir, recursive) {
this.recursive = recursive;
- this.fs = fs;
- this.inDir = this.fs.canonical(inDir);
- this.outDir = this.fs.canonical(outDir);
+ this.fs = fs;
+ this.inDir = this.fs.canonical(inDir);
+ this.targetDir = this.fs.canonical(outDir);
this.verbose = true;
});
@@ -1257,14 +1257,14 @@ JS2.Class.extend('Updater', function(KLASS, OO){
for(var _i1=0,_c1=subs,_l1=_c1.length,sub;(sub=_c1[_i1])||(_i1<_l1);_i1++){
var path = dir + '/' + sub;
if (this.fs.isDirectory(path)) {
- this.fs.mkdir(path.replace(this.inDir, this.outDir));
+ this.fs.mkdir(path.replace(this.inDir, this.targetDir));
this.matchDirs(path);
}
}
});
OO.addMember("tryUpdate",function (file, force, funct) {
- var outFile = file.replace(this.inDir, this.outDir).replace(/\.js2$/, '.js');
+ var outFile = file.replace(this.inDir, this.targetDir).replace(/\.js2$/, '.js');
var dir = this.fs.dirname(file);
if (! this.fs.isDirectory(dir)) this.fs.mkpath(dir);
@@ -1514,6 +1514,8 @@ JS2.Class.extend('JSML', function(KLASS, OO){
});
OO.addMember("processLine",function (line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -1551,6 +1553,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
+ OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
OO.addMember("initialize",function (line) {
this.children = [];
@@ -1610,6 +1613,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
});
OO.addMember("flatten",function () {
@@ -1625,8 +1634,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
25 flavors/browser-full.js
@@ -1242,9 +1242,9 @@ JS2.Class.extend('FileSystem', function(KLASS, OO){
JS2.Class.extend('Updater', function(KLASS, OO){
OO.addMember("initialize",function (fs, inDir, outDir, recursive) {
this.recursive = recursive;
- this.fs = fs;
- this.inDir = this.fs.canonical(inDir);
- this.outDir = this.fs.canonical(outDir);
+ this.fs = fs;
+ this.inDir = this.fs.canonical(inDir);
+ this.targetDir = this.fs.canonical(outDir);
this.verbose = true;
});
@@ -1261,14 +1261,14 @@ JS2.Class.extend('Updater', function(KLASS, OO){
for(var _i1=0,_c1=subs,_l1=_c1.length,sub;(sub=_c1[_i1])||(_i1<_l1);_i1++){
var path = dir + '/' + sub;
if (this.fs.isDirectory(path)) {
- this.fs.mkdir(path.replace(this.inDir, this.outDir));
+ this.fs.mkdir(path.replace(this.inDir, this.targetDir));
this.matchDirs(path);
}
}
});
OO.addMember("tryUpdate",function (file, force, funct) {
- var outFile = file.replace(this.inDir, this.outDir).replace(/\.js2$/, '.js');
+ var outFile = file.replace(this.inDir, this.targetDir).replace(/\.js2$/, '.js');
var dir = this.fs.dirname(file);
if (! this.fs.isDirectory(dir)) this.fs.mkpath(dir);
@@ -1518,6 +1518,8 @@ JS2.Class.extend('JSML', function(KLASS, OO){
});
OO.addMember("processLine",function (line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -1555,6 +1557,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
+ OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
OO.addMember("initialize",function (line) {
this.children = [];
@@ -1614,6 +1617,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
});
OO.addMember("flatten",function () {
@@ -1629,8 +1638,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
15 flavors/browser.js
@@ -299,6 +299,8 @@ JS2.Array.prototype.any = function() {
});
OO.addMember("processLine",function (line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -336,6 +338,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
+ OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
OO.addMember("initialize",function (line) {
this.children = [];
@@ -395,6 +398,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
});
OO.addMember("flatten",function () {
@@ -410,8 +419,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
25 flavors/node.js
@@ -1238,9 +1238,9 @@ JS2.Class.extend('FileSystem', function(KLASS, OO){
JS2.Class.extend('Updater', function(KLASS, OO){
OO.addMember("initialize",function (fs, inDir, outDir, recursive) {
this.recursive = recursive;
- this.fs = fs;
- this.inDir = this.fs.canonical(inDir);
- this.outDir = this.fs.canonical(outDir);
+ this.fs = fs;
+ this.inDir = this.fs.canonical(inDir);
+ this.targetDir = this.fs.canonical(outDir);
this.verbose = true;
});
@@ -1257,14 +1257,14 @@ JS2.Class.extend('Updater', function(KLASS, OO){
for(var _i1=0,_c1=subs,_l1=_c1.length,sub;(sub=_c1[_i1])||(_i1<_l1);_i1++){
var path = dir + '/' + sub;
if (this.fs.isDirectory(path)) {
- this.fs.mkdir(path.replace(this.inDir, this.outDir));
+ this.fs.mkdir(path.replace(this.inDir, this.targetDir));
this.matchDirs(path);
}
}
});
OO.addMember("tryUpdate",function (file, force, funct) {
- var outFile = file.replace(this.inDir, this.outDir).replace(/\.js2$/, '.js');
+ var outFile = file.replace(this.inDir, this.targetDir).replace(/\.js2$/, '.js');
var dir = this.fs.dirname(file);
if (! this.fs.isDirectory(dir)) this.fs.mkpath(dir);
@@ -1514,6 +1514,8 @@ JS2.Class.extend('JSML', function(KLASS, OO){
});
OO.addMember("processLine",function (line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -1551,6 +1553,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
+ OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
OO.addMember("initialize",function (line) {
this.children = [];
@@ -1610,6 +1613,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
});
OO.addMember("flatten",function () {
@@ -1625,8 +1634,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
25 flavors/ringo-full.js
@@ -1240,9 +1240,9 @@ JS2.Class.extend('FileSystem', function(KLASS, OO){
JS2.Class.extend('Updater', function(KLASS, OO){
OO.addMember("initialize",function (fs, inDir, outDir, recursive) {
this.recursive = recursive;
- this.fs = fs;
- this.inDir = this.fs.canonical(inDir);
- this.outDir = this.fs.canonical(outDir);
+ this.fs = fs;
+ this.inDir = this.fs.canonical(inDir);
+ this.targetDir = this.fs.canonical(outDir);
this.verbose = true;
});
@@ -1259,14 +1259,14 @@ JS2.Class.extend('Updater', function(KLASS, OO){
for(var _i1=0,_c1=subs,_l1=_c1.length,sub;(sub=_c1[_i1])||(_i1<_l1);_i1++){
var path = dir + '/' + sub;
if (this.fs.isDirectory(path)) {
- this.fs.mkdir(path.replace(this.inDir, this.outDir));
+ this.fs.mkdir(path.replace(this.inDir, this.targetDir));
this.matchDirs(path);
}
}
});
OO.addMember("tryUpdate",function (file, force, funct) {
- var outFile = file.replace(this.inDir, this.outDir).replace(/\.js2$/, '.js');
+ var outFile = file.replace(this.inDir, this.targetDir).replace(/\.js2$/, '.js');
var dir = this.fs.dirname(file);
if (! this.fs.isDirectory(dir)) this.fs.mkpath(dir);
@@ -1516,6 +1516,8 @@ JS2.Class.extend('JSML', function(KLASS, OO){
});
OO.addMember("processLine",function (line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -1553,6 +1555,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
+ OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
OO.addMember("initialize",function (line) {
this.children = [];
@@ -1612,6 +1615,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
});
OO.addMember("flatten",function () {
@@ -1627,8 +1636,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
15 flavors/ringo.js
@@ -296,6 +296,8 @@ JS2.Array.prototype.any = function() {
});
OO.addMember("processLine",function (line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -333,6 +335,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
+ OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
OO.addMember("initialize",function (line) {
this.children = [];
@@ -392,6 +395,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
});
OO.addMember("flatten",function () {
@@ -407,8 +416,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
25 flavors/ruby.js
@@ -1238,9 +1238,9 @@ JS2.Class.extend('FileSystem', function(KLASS, OO){
JS2.Class.extend('Updater', function(KLASS, OO){
OO.addMember("initialize",function (fs, inDir, outDir, recursive) {
this.recursive = recursive;
- this.fs = fs;
- this.inDir = this.fs.canonical(inDir);
- this.outDir = this.fs.canonical(outDir);
+ this.fs = fs;
+ this.inDir = this.fs.canonical(inDir);
+ this.targetDir = this.fs.canonical(outDir);
this.verbose = true;
});
@@ -1257,14 +1257,14 @@ JS2.Class.extend('Updater', function(KLASS, OO){
for(var _i1=0,_c1=subs,_l1=_c1.length,sub;(sub=_c1[_i1])||(_i1<_l1);_i1++){
var path = dir + '/' + sub;
if (this.fs.isDirectory(path)) {
- this.fs.mkdir(path.replace(this.inDir, this.outDir));
+ this.fs.mkdir(path.replace(this.inDir, this.targetDir));
this.matchDirs(path);
}
}
});
OO.addMember("tryUpdate",function (file, force, funct) {
- var outFile = file.replace(this.inDir, this.outDir).replace(/\.js2$/, '.js');
+ var outFile = file.replace(this.inDir, this.targetDir).replace(/\.js2$/, '.js');
var dir = this.fs.dirname(file);
if (! this.fs.isDirectory(dir)) this.fs.mkpath(dir);
@@ -1514,6 +1514,8 @@ JS2.Class.extend('JSML', function(KLASS, OO){
});
OO.addMember("processLine",function (line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -1551,6 +1553,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
+ OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
OO.addMember("initialize",function (line) {
this.children = [];
@@ -1610,6 +1613,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
});
OO.addMember("flatten",function () {
@@ -1625,8 +1634,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
15 src/Common/JSML.js2
@@ -27,6 +27,8 @@ class JSML {
}
function processLine(line) {
+ if (line.match(/^\s*$/)) return;
+
var ele = new JS2.JSMLElement(line);
var scope = this.getScope();
@@ -64,6 +66,7 @@ class JSMLElement {
var TOKEN_REGEX = /(\%|\#|\.)([\w][\w\-]*)/g;
var JS_REGEX = /^(-|=)(.*)$/g;
var SCOPE_OFFSET = 1;
+ var SELF_CLOSING = { area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null };
function initialize(line) {
this.children = [];
@@ -123,6 +126,12 @@ class JSMLElement {
if (!this.nodeType && (this.classes.length || this.nodeID)) {
this.nodeType = 'div';
}
+
+ if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
+ this.selfClose = '/';
+ } else {
+ this.selfClose = '';
+ }
}
function flatten() {
@@ -138,8 +147,10 @@ class JSMLElement {
if (this.nodeType) {
this.handleJsEQ(out);
this.handleContent(out);
- out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
- out.push('out.push(' + JSON.stringify(%{</#{this.nodeType}>}) + ');\n');
+ out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
+ if (this.selfClose == '') {
+ out.push('out.push(' + JSON.stringify(%{</#{this.nodeType}>}) + ');\n');
+ }
} else {
this.handleJsExec(out);
this.handleJsEQ(out);
View
10 src/Common/Updater.js2
@@ -1,9 +1,9 @@
class Updater {
function initialize(fs, inDir, outDir, recursive) {
this.recursive = recursive;
- this.fs = fs;
- this.inDir = this.fs.canonical(inDir);
- this.outDir = this.fs.canonical(outDir);
+ this.fs = fs;
+ this.inDir = this.fs.canonical(inDir);
+ this.targetDir = this.fs.canonical(outDir);
this.verbose = true;
}
@@ -20,14 +20,14 @@ class Updater {
foreach (var sub in subs) {
var path = dir + '/' + sub;
if (this.fs.isDirectory(path)) {
- this.fs.mkdir(path.replace(this.inDir, this.outDir));
+ this.fs.mkdir(path.replace(this.inDir, this.targetDir));
this.matchDirs(path);
}
}
}
function tryUpdate(file, force, funct) {
- var outFile = file.replace(this.inDir, this.outDir).replace(/\.js2$/, '.js');
+ var outFile = file.replace(this.inDir, this.targetDir).replace(/\.js2$/, '.js');
var dir = this.fs.dirname(file);
if (! this.fs.isDirectory(dir)) this.fs.mkpath(dir);
View
7 tests/src/jsml.js2
@@ -15,11 +15,18 @@ var text2 = <<END:jsml
world
END
+var text3 = <<END:jsml
+ %h1 Hello
+
+ %input
+END
+
js2.test(#(assert) {
var result = text.result({ hello:"yo", bar:"foo", yo:['hello', 'world'] });
var expected = '<div>hello</div><div>world</div><div class="yo"><div class="hello">foo</div><div class="world"></div></div><span class="yo" href="/">Hello world</span>yo'
assert.eq(expected, result);
assert.eq('<div class="hello-world">helloworld</div>', text2.result());
+ assert.eq('<h1>Hello</h1><input/>', text3.result());
});
Please sign in to comment.
Something went wrong with that request. Please try again.