Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Multiple content

  • Loading branch information...
commit a2f57204ab1284c9f8a15d2a4a99101b8844dcfd 1 parent 9d49195
@jeffsu authored
View
5 CHANGELOG
@@ -1,3 +1,6 @@
+0.3.14
+ * JSML: added plain content children
+
0.3.13
* fixed problem that doesn't allow toString methods
* fixed string sanitizer problem with double quotes
@@ -22,7 +25,7 @@
* fixed regex/divide issue
0.3.8
- * fied "render"
+ * fixed "render"
* fixed comment block bug
* using target-dir instead of out-dir
View
2  VERSION
@@ -1 +1 @@
-0.3.13
+0.3.14
View
20 dist/browser/js2-full.js
@@ -1550,7 +1550,7 @@ JS2.Class.extend('JSML', function(KLASS, OO){
JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("SCOPE_REGEX",/^(\s*)(.*)$/);
- OO.addMember("SPLIT_REGEX",/^([^=-\s\{]*)(\{.*\})?(=|-)?(?:\s*)(.*)$/);
+ OO.addMember("SPLIT_REGEX",/^((?:\.|\#|\%)[^=-\s\{]*)?(\{.*\})?(=|-)?(?:\s*)(.*)$/);
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w-]+)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
@@ -1587,14 +1587,16 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
var jsType = splitted[3];
var content = splitted[4];
- tokens.replace(this.TOKEN_REGEX, function(match, type, name){
- switch(type) {
- case '%': self.nodeType = name; break;
- case '.': self.classes.push(name); break;
- case '#': self.nodeID = name; break;
- }
- return '';
- });
+ if (tokens) {
+ tokens.replace(this.TOKEN_REGEX, function(match, type, name){
+ switch(type) {
+ case '%': self.nodeType = name; break;
+ case '.': self.classes.push(name); break;
+ case '#': self.nodeID = name; break;
+ }
+ return '';
+ });
+ }
if (jsType == '=') {
this.jsEQ = content;
View
20 dist/gem/lib/js2/js2.js
@@ -1546,7 +1546,7 @@ JS2.Class.extend('JSML', function(KLASS, OO){
JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("SCOPE_REGEX",/^(\s*)(.*)$/);
- OO.addMember("SPLIT_REGEX",/^([^=-\s\{]*)(\{.*\})?(=|-)?(?:\s*)(.*)$/);
+ OO.addMember("SPLIT_REGEX",/^((?:\.|\#|\%)[^=-\s\{]*)?(\{.*\})?(=|-)?(?:\s*)(.*)$/);
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w-]+)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
@@ -1583,14 +1583,16 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
var jsType = splitted[3];
var content = splitted[4];
- tokens.replace(this.TOKEN_REGEX, function(match, type, name){
- switch(type) {
- case '%': self.nodeType = name; break;
- case '.': self.classes.push(name); break;
- case '#': self.nodeID = name; break;
- }
- return '';
- });
+ if (tokens) {
+ tokens.replace(this.TOKEN_REGEX, function(match, type, name){
+ switch(type) {
+ case '%': self.nodeType = name; break;
+ case '.': self.classes.push(name); break;
+ case '#': self.nodeID = name; break;
+ }
+ return '';
+ });
+ }
if (jsType == '=') {
this.jsEQ = content;
View
20 dist/npm/lib/js2.js
@@ -1546,7 +1546,7 @@ JS2.Class.extend('JSML', function(KLASS, OO){
JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("SCOPE_REGEX",/^(\s*)(.*)$/);
- OO.addMember("SPLIT_REGEX",/^([^=-\s\{]*)(\{.*\})?(=|-)?(?:\s*)(.*)$/);
+ OO.addMember("SPLIT_REGEX",/^((?:\.|\#|\%)[^=-\s\{]*)?(\{.*\})?(=|-)?(?:\s*)(.*)$/);
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w-]+)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
@@ -1583,14 +1583,16 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
var jsType = splitted[3];
var content = splitted[4];
- tokens.replace(this.TOKEN_REGEX, function(match, type, name){
- switch(type) {
- case '%': self.nodeType = name; break;
- case '.': self.classes.push(name); break;
- case '#': self.nodeID = name; break;
- }
- return '';
- });
+ if (tokens) {
+ tokens.replace(this.TOKEN_REGEX, function(match, type, name){
+ switch(type) {
+ case '%': self.nodeType = name; break;
+ case '.': self.classes.push(name); break;
+ case '#': self.nodeID = name; break;
+ }
+ return '';
+ });
+ }
if (jsType == '=') {
this.jsEQ = content;
View
20 flavors/browser-full.js
@@ -1550,7 +1550,7 @@ JS2.Class.extend('JSML', function(KLASS, OO){
JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("SCOPE_REGEX",/^(\s*)(.*)$/);
- OO.addMember("SPLIT_REGEX",/^([^=-\s\{]*)(\{.*\})?(=|-)?(?:\s*)(.*)$/);
+ OO.addMember("SPLIT_REGEX",/^((?:\.|\#|\%)[^=-\s\{]*)?(\{.*\})?(=|-)?(?:\s*)(.*)$/);
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w-]+)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
@@ -1587,14 +1587,16 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
var jsType = splitted[3];
var content = splitted[4];
- tokens.replace(this.TOKEN_REGEX, function(match, type, name){
- switch(type) {
- case '%': self.nodeType = name; break;
- case '.': self.classes.push(name); break;
- case '#': self.nodeID = name; break;
- }
- return '';
- });
+ if (tokens) {
+ tokens.replace(this.TOKEN_REGEX, function(match, type, name){
+ switch(type) {
+ case '%': self.nodeType = name; break;
+ case '.': self.classes.push(name); break;
+ case '#': self.nodeID = name; break;
+ }
+ return '';
+ });
+ }
if (jsType == '=') {
this.jsEQ = content;
View
20 flavors/node.js
@@ -1546,7 +1546,7 @@ JS2.Class.extend('JSML', function(KLASS, OO){
JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("SCOPE_REGEX",/^(\s*)(.*)$/);
- OO.addMember("SPLIT_REGEX",/^([^=-\s\{]*)(\{.*\})?(=|-)?(?:\s*)(.*)$/);
+ OO.addMember("SPLIT_REGEX",/^((?:\.|\#|\%)[^=-\s\{]*)?(\{.*\})?(=|-)?(?:\s*)(.*)$/);
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w-]+)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
@@ -1583,14 +1583,16 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
var jsType = splitted[3];
var content = splitted[4];
- tokens.replace(this.TOKEN_REGEX, function(match, type, name){
- switch(type) {
- case '%': self.nodeType = name; break;
- case '.': self.classes.push(name); break;
- case '#': self.nodeID = name; break;
- }
- return '';
- });
+ if (tokens) {
+ tokens.replace(this.TOKEN_REGEX, function(match, type, name){
+ switch(type) {
+ case '%': self.nodeType = name; break;
+ case '.': self.classes.push(name); break;
+ case '#': self.nodeID = name; break;
+ }
+ return '';
+ });
+ }
if (jsType == '=') {
this.jsEQ = content;
View
20 flavors/ringo-full.js
@@ -1548,7 +1548,7 @@ JS2.Class.extend('JSML', function(KLASS, OO){
JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("SCOPE_REGEX",/^(\s*)(.*)$/);
- OO.addMember("SPLIT_REGEX",/^([^=-\s\{]*)(\{.*\})?(=|-)?(?:\s*)(.*)$/);
+ OO.addMember("SPLIT_REGEX",/^((?:\.|\#|\%)[^=-\s\{]*)?(\{.*\})?(=|-)?(?:\s*)(.*)$/);
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w-]+)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
@@ -1585,14 +1585,16 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
var jsType = splitted[3];
var content = splitted[4];
- tokens.replace(this.TOKEN_REGEX, function(match, type, name){
- switch(type) {
- case '%': self.nodeType = name; break;
- case '.': self.classes.push(name); break;
- case '#': self.nodeID = name; break;
- }
- return '';
- });
+ if (tokens) {
+ tokens.replace(this.TOKEN_REGEX, function(match, type, name){
+ switch(type) {
+ case '%': self.nodeType = name; break;
+ case '.': self.classes.push(name); break;
+ case '#': self.nodeID = name; break;
+ }
+ return '';
+ });
+ }
if (jsType == '=') {
this.jsEQ = content;
View
20 flavors/ruby.js
@@ -1546,7 +1546,7 @@ JS2.Class.extend('JSML', function(KLASS, OO){
JS2.Class.extend('JSMLElement', function(KLASS, OO){
OO.addMember("SCOPE_REGEX",/^(\s*)(.*)$/);
- OO.addMember("SPLIT_REGEX",/^([^=-\s\{]*)(\{.*\})?(=|-)?(?:\s*)(.*)$/);
+ OO.addMember("SPLIT_REGEX",/^((?:\.|\#|\%)[^=-\s\{]*)?(\{.*\})?(=|-)?(?:\s*)(.*)$/);
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w-]+)/g);
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
OO.addMember("SCOPE_OFFSET",1);
@@ -1583,14 +1583,16 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
var jsType = splitted[3];
var content = splitted[4];
- tokens.replace(this.TOKEN_REGEX, function(match, type, name){
- switch(type) {
- case '%': self.nodeType = name; break;
- case '.': self.classes.push(name); break;
- case '#': self.nodeID = name; break;
- }
- return '';
- });
+ if (tokens) {
+ tokens.replace(this.TOKEN_REGEX, function(match, type, name){
+ switch(type) {
+ case '%': self.nodeType = name; break;
+ case '.': self.classes.push(name); break;
+ case '#': self.nodeID = name; break;
+ }
+ return '';
+ });
+ }
if (jsType == '=') {
this.jsEQ = content;
View
25 src/Common/JSML.js2
@@ -16,8 +16,9 @@ class JSML {
var toEval = 'function process() { var out = [];\n' + this.flatten().join('') + '\n return out.join("");\n}';
eval(toEval);
- this.result = function(hash) {
- return process.call(hash);
+ this.result = function(bound) {
+ bound = bound || {};
+ return process.call(bound);
};
}
@@ -59,7 +60,7 @@ class JSML {
class JSMLElement {
var SCOPE_REGEX = /^(\s*)(.*)$/;
- var SPLIT_REGEX = /^([^=-\s\{]*)(\{.*\})?(=|-)?(?:\s*)(.*)$/;
+ var SPLIT_REGEX = /^((?:\.|\#|\%)[^=-\s\{]*)?(\{.*\})?(=|-)?(?:\s*)(.*)$/;
var TOKEN_REGEX = /(\%|\#|\.)([\w-]+)/g;
var JS_REGEX = /^(-|=)(.*)$/g;
var SCOPE_OFFSET = 1;
@@ -96,14 +97,16 @@ class JSMLElement {
var jsType = splitted[3];
var content = splitted[4];
- tokens.replace(this.TOKEN_REGEX, #(match, type, name) {
- switch(type) {
- case '%': self.nodeType = name; break;
- case '.': self.classes.push(name); break;
- case '#': self.nodeID = name; break;
- }
- return '';
- });
+ if (tokens) {
+ tokens.replace(this.TOKEN_REGEX, #(match, type, name) {
+ switch(type) {
+ case '%': self.nodeType = name; break;
+ case '.': self.classes.push(name); break;
+ case '#': self.nodeID = name; break;
+ }
+ return '';
+ });
+ }
if (jsType == '=') {
this.jsEQ = content;
View
8 tests/src/jsml.js2
@@ -9,9 +9,17 @@ var text = <<END:jsml
= this.hello
END
+var text2 = <<END:jsml
+ %div
+ hello
+ world
+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="hello" href="/">Hello world</span>yo'
assert.eq(expected, result);
+ assert.eq('<div>helloworld</div>', text2.result());
});
Please sign in to comment.
Something went wrong with that request. Please try again.