Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: node_js

node_js:
- '0.8'
- '0.10'
- '0.12'
- 6
- 8
- 12

script:
- grunt --force
120 changes: 70 additions & 50 deletions tests/expected/amdTest/advanced-example.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,84 @@
define(function(){
var template = function(__obj) {
var _safe = function(value) {
if (typeof value === 'undefined' && value == null)
value = '';
var result = new String(value);
result.ecoSafe = true;
return result;
var templatefunction(__obj) {
if (!__obj) __obj = {};
var __out = [], __capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return __safe(result);
}, __sanitize = function(value) {
if (value && value.ecoSafe) {
return value;
} else if (typeof value !== 'undefined' && value != null) {
return __escape(value);
} else {
return '';
}
}, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
__safe = __obj.safe = function(value) {
if (value && value.ecoSafe) {
return value;
} else {
if (!(typeof value !== 'undefined' && value != null)) value = '';
var result = new String(value);
result.ecoSafe = true;
return result;
}
};
return (function() {
var __out = [], __self = this, _print = function(value) {
if (typeof value !== 'undefined' && value != null)
__out.push(value.ecoSafe ? value : __self.escape(value));
}, _capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return _safe(result);
};
if (!__escape) {
__escape = __obj.escape = function(value) {
var escapeMap = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'`': '&#x60;'
};

var escaper = function(match) {
return escapeMap[match];
};

var source = '(?:' + Object.keys(escapeMap).join('|') + ')';
var testRegexp = RegExp(source);
var replaceRegexp = RegExp(source, 'g');

value = value == null ? '' : '' + value;
return testRegexp.test(value) ? value.replace(replaceRegexp, escaper) : value;
}
}
(function() {
(function() {
var project, _i, _len, _ref;
var i, len, project, ref;

if (this.projects.length) {
_print(_safe('\n '));
_ref = this.projects;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
project = _ref[_i];
_print(_safe('\n <a href="'));
_print(project.url);
_print(_safe('">'));
_print(project.name);
_print(_safe('</a>\n <p>'));
_print(project.description);
_print(_safe('</p>\n '));
__out.push('\n ');
ref = this.projects;
for (i = 0, len = ref.length; i < len; i++) {
project = ref[i];
__out.push('\n <a href="');
__out.push(__sanitize(project.url));
__out.push('">');
__out.push(__sanitize(project.name));
__out.push('</a>\n <p>');
__out.push(__sanitize(project.description));
__out.push('</p>\n ');
}
_print(_safe('\n'));
__out.push('\n');
} else {
_print(_safe('\n No projects\n'));
__out.push('\n No projects\n');
}

_print(_safe('\n'));
__out.push('\n');

}).call(this);

return __out.join('');
}).call((function() {
var obj = {
escape: function(value) {
return ('' + value)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
},
safe: _safe
}, key;
for (key in __obj) obj[key] = __obj[key];
return obj;
})());
};
}).call(__obj);
__obj.safe = __objSafe, __obj.escape = __escape;
return __out.join('');
}
return template;
});
94 changes: 57 additions & 37 deletions tests/expected/amdTest/example.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,66 @@
define(function(){
var template = function(__obj) {
var _safe = function(value) {
if (typeof value === 'undefined' && value == null)
value = '';
var result = new String(value);
result.ecoSafe = true;
return result;
var templatefunction(__obj) {
if (!__obj) __obj = {};
var __out = [], __capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return __safe(result);
}, __sanitize = function(value) {
if (value && value.ecoSafe) {
return value;
} else if (typeof value !== 'undefined' && value != null) {
return __escape(value);
} else {
return '';
}
}, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
__safe = __obj.safe = function(value) {
if (value && value.ecoSafe) {
return value;
} else {
if (!(typeof value !== 'undefined' && value != null)) value = '';
var result = new String(value);
result.ecoSafe = true;
return result;
}
};
return (function() {
var __out = [], __self = this, _print = function(value) {
if (typeof value !== 'undefined' && value != null)
__out.push(value.ecoSafe ? value : __self.escape(value));
}, _capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return _safe(result);
};
if (!__escape) {
__escape = __obj.escape = function(value) {
var escapeMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'`': '&#x60;'
};

var escaper = function(match) {
return escapeMap[match];
};

var source = '(?:' + Object.keys(escapeMap).join('|') + ')';
var testRegexp = RegExp(source);
var replaceRegexp = RegExp(source, 'g');

value = value == null ? '' : '' + value;
return testRegexp.test(value) ? value.replace(replaceRegexp, escaper) : value;
}
}
(function() {
(function() {
_print(this.project.description);
__out.push(__sanitize(this.project.description));

_print(_safe('\n'));
__out.push('\n');

}).call(this);

return __out.join('');
}).call((function() {
var obj = {
escape: function(value) {
return ('' + value)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
},
safe: _safe
}, key;
for (key in __obj) obj[key] = __obj[key];
return obj;
})());
};
}).call(__obj);
__obj.safe = __objSafe, __obj.escape = __escape;
return __out.join('');
}
return template;
});
94 changes: 57 additions & 37 deletions tests/expected/amdTest/nested-example.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,66 @@
define(function(){
var template = function(__obj) {
var _safe = function(value) {
if (typeof value === 'undefined' && value == null)
value = '';
var result = new String(value);
result.ecoSafe = true;
return result;
var templatefunction(__obj) {
if (!__obj) __obj = {};
var __out = [], __capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return __safe(result);
}, __sanitize = function(value) {
if (value && value.ecoSafe) {
return value;
} else if (typeof value !== 'undefined' && value != null) {
return __escape(value);
} else {
return '';
}
}, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
__safe = __obj.safe = function(value) {
if (value && value.ecoSafe) {
return value;
} else {
if (!(typeof value !== 'undefined' && value != null)) value = '';
var result = new String(value);
result.ecoSafe = true;
return result;
}
};
return (function() {
var __out = [], __self = this, _print = function(value) {
if (typeof value !== 'undefined' && value != null)
__out.push(value.ecoSafe ? value : __self.escape(value));
}, _capture = function(callback) {
var out = __out, result;
__out = [];
callback.call(this);
result = __out.join('');
__out = out;
return _safe(result);
};
if (!__escape) {
__escape = __obj.escape = function(value) {
var escapeMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'`': '&#x60;'
};

var escaper = function(match) {
return escapeMap[match];
};

var source = '(?:' + Object.keys(escapeMap).join('|') + ')';
var testRegexp = RegExp(source);
var replaceRegexp = RegExp(source, 'g');

value = value == null ? '' : '' + value;
return testRegexp.test(value) ? value.replace(replaceRegexp, escaper) : value;
}
}
(function() {
(function() {
_print(this.project.description);
__out.push(__sanitize(this.project.description));

_print(_safe('\n'));
__out.push('\n');

}).call(this);

return __out.join('');
}).call((function() {
var obj = {
escape: function(value) {
return ('' + value)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
},
safe: _safe
}, key;
for (key in __obj) obj[key] = __obj[key];
return obj;
})());
};
}).call(__obj);
__obj.safe = __objSafe, __obj.escape = __escape;
return __out.join('');
}
return template;
});
Loading