From f533681bc76e5438677d1f1c2ba0c6b14e3bc671 Mon Sep 17 00:00:00 2001 From: cesine Date: Tue, 21 Jul 2020 16:27:06 -0400 Subject: [PATCH 1/5] try using lastest eco 1.1.0-rc-3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8e4842e..fa5ad0c 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "node": ">=0.8" }, "dependencies": { - "eco": "1.0.3" + "eco": "1.1.0-rc-3" }, "devDependencies": { "grunt": "1.0.4", From feab960b49bd4bf3da5196d5f33ce40782de6ab0 Mon Sep 17 00:00:00 2001 From: cesine Date: Wed, 22 Jul 2020 11:27:38 -0400 Subject: [PATCH 2/5] compile returns a function not identifier = https://github.com/sstephenson/eco/commit/8ab3bec5700db98915a873907fe4fc238366c9e0 --- tasks/eco.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/eco.js b/tasks/eco.js index 63fb484..15fa3e3 100644 --- a/tasks/eco.js +++ b/tasks/eco.js @@ -35,7 +35,8 @@ module.exports = function(grunt) { } try { - output = eco.compile(grunt.file.read(src)).replace(/module\.exports/, ''); + output = ' = ' + eco.compile(grunt.file.read(src)).toString(); + grunt.log.debug('output', output); } catch (e) { grunt.log.error("Error in " + src + ":\n" + e); grunt.fail.warn("Eco failed to compile " + src + "."); From 7786d0c7f9c15392be80ad72b8f7032f84aced0e Mon Sep 17 00:00:00 2001 From: cesine Date: Wed, 22 Jul 2020 11:30:43 -0400 Subject: [PATCH 3/5] update fixtures --- tests/expected/amdTest/advanced-example.js | 94 +++---- tests/expected/amdTest/example.js | 76 +++--- tests/expected/amdTest/nested-example.js | 76 +++--- tests/expected/basePathFunctionTest/all.js | 246 ++++++++++-------- tests/expected/basePathStringTest/all.js | 246 ++++++++++-------- tests/expected/expandTest/advanced-example.js | 94 +++---- tests/expected/expandTest/example.js | 76 +++--- tests/expected/expandTest/nested-example.js | 76 +++--- tests/expected/filesTest/all.js | 246 ++++++++++-------- tests/expected/filesTest/flatOnly.js | 170 ++++++------ tests/expected/noJstGlobalCheckTest/all.js | 246 ++++++++++-------- tests/expected/srcDestTest/all.js | 246 ++++++++++-------- 12 files changed, 1015 insertions(+), 877 deletions(-) diff --git a/tests/expected/amdTest/advanced-example.js b/tests/expected/amdTest/advanced-example.js index 39846d9..eaaf26a 100644 --- a/tests/expected/amdTest/advanced-example.js +++ b/tests/expected/amdTest/advanced-example.js @@ -1,64 +1,70 @@ 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; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (function() { (function() { var i, len, project, ref; if (this.projects.length) { - _print(_safe('\n ')); + __out.push('\n '); ref = this.projects; for (i = 0, len = ref.length; i < len; i++) { project = ref[i]; - _print(_safe('\n ')); - _print(project.name); - _print(_safe('\n

')); - _print(project.description); - _print(_safe('

\n ')); + __out.push('\n '); + __out.push(__sanitize(project.name)); + __out.push('\n

'); + __out.push(__sanitize(project.description)); + __out.push('

\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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - 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; }); diff --git a/tests/expected/amdTest/example.js b/tests/expected/amdTest/example.js index 208d80f..bd71996 100644 --- a/tests/expected/amdTest/example.js +++ b/tests/expected/amdTest/example.js @@ -1,46 +1,52 @@ 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; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - 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; }); diff --git a/tests/expected/amdTest/nested-example.js b/tests/expected/amdTest/nested-example.js index 208d80f..bd71996 100644 --- a/tests/expected/amdTest/nested-example.js +++ b/tests/expected/amdTest/nested-example.js @@ -1,46 +1,52 @@ 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; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - 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; }); diff --git a/tests/expected/basePathFunctionTest/all.js b/tests/expected/basePathFunctionTest/all.js index fb05c81..c7a90e6 100644 --- a/tests/expected/basePathFunctionTest/all.js +++ b/tests/expected/basePathFunctionTest/all.js @@ -2,158 +2,176 @@ if (!window.JST) { window.JST = {}; } window.JST["advanced"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (function() { (function() { var i, len, project, ref; if (this.projects.length) { - _print(_safe('\n ')); + __out.push('\n '); ref = this.projects; for (i = 0, len = ref.length; i < len; i++) { project = ref[i]; - _print(_safe('\n ')); - _print(project.name); - _print(_safe('\n

')); - _print(project.description); - _print(_safe('

\n ')); + __out.push('\n '); + __out.push(__sanitize(project.name)); + __out.push('\n

'); + __out.push(__sanitize(project.description)); + __out.push('

\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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} if (!window.JST) { window.JST = {}; } window.JST["example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} if (!window.JST) { window.JST = {}; } window.JST["nested/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} diff --git a/tests/expected/basePathStringTest/all.js b/tests/expected/basePathStringTest/all.js index 4c987a5..540047d 100644 --- a/tests/expected/basePathStringTest/all.js +++ b/tests/expected/basePathStringTest/all.js @@ -2,158 +2,176 @@ if (!window.JST) { window.JST = {}; } window.JST["advanced-example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (function() { (function() { var i, len, project, ref; if (this.projects.length) { - _print(_safe('\n ')); + __out.push('\n '); ref = this.projects; for (i = 0, len = ref.length; i < len; i++) { project = ref[i]; - _print(_safe('\n ')); - _print(project.name); - _print(_safe('\n

')); - _print(project.description); - _print(_safe('

\n ')); + __out.push('\n '); + __out.push(__sanitize(project.name)); + __out.push('\n

'); + __out.push(__sanitize(project.description)); + __out.push('

\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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} if (!window.JST) { window.JST = {}; } window.JST["example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} if (!window.JST) { window.JST = {}; } window.JST["nested/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} diff --git a/tests/expected/expandTest/advanced-example.js b/tests/expected/expandTest/advanced-example.js index 2c7b299..3e6b506 100644 --- a/tests/expected/expandTest/advanced-example.js +++ b/tests/expected/expandTest/advanced-example.js @@ -2,63 +2,69 @@ if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/advanced-example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (function() { (function() { var i, len, project, ref; if (this.projects.length) { - _print(_safe('\n ')); + __out.push('\n '); ref = this.projects; for (i = 0, len = ref.length; i < len; i++) { project = ref[i]; - _print(_safe('\n ')); - _print(project.name); - _print(_safe('\n

')); - _print(project.description); - _print(_safe('

\n ')); + __out.push('\n '); + __out.push(__sanitize(project.name)); + __out.push('\n

'); + __out.push(__sanitize(project.description)); + __out.push('

\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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} diff --git a/tests/expected/expandTest/example.js b/tests/expected/expandTest/example.js index 3bcd9b3..6edeb45 100644 --- a/tests/expected/expandTest/example.js +++ b/tests/expected/expandTest/example.js @@ -2,45 +2,51 @@ if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} diff --git a/tests/expected/expandTest/nested-example.js b/tests/expected/expandTest/nested-example.js index 23c6c8e..fbe6f9c 100644 --- a/tests/expected/expandTest/nested-example.js +++ b/tests/expected/expandTest/nested-example.js @@ -2,45 +2,51 @@ if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/nested/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} diff --git a/tests/expected/filesTest/all.js b/tests/expected/filesTest/all.js index a43cd15..20453d2 100644 --- a/tests/expected/filesTest/all.js +++ b/tests/expected/filesTest/all.js @@ -2,158 +2,176 @@ if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/advanced-example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (function() { (function() { var i, len, project, ref; if (this.projects.length) { - _print(_safe('\n ')); + __out.push('\n '); ref = this.projects; for (i = 0, len = ref.length; i < len; i++) { project = ref[i]; - _print(_safe('\n ')); - _print(project.name); - _print(_safe('\n

')); - _print(project.description); - _print(_safe('

\n ')); + __out.push('\n '); + __out.push(__sanitize(project.name)); + __out.push('\n

'); + __out.push(__sanitize(project.description)); + __out.push('

\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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/nested/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} diff --git a/tests/expected/filesTest/flatOnly.js b/tests/expected/filesTest/flatOnly.js index 8a06e03..4699339 100644 --- a/tests/expected/filesTest/flatOnly.js +++ b/tests/expected/filesTest/flatOnly.js @@ -2,111 +2,123 @@ if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/advanced-example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (function() { (function() { var i, len, project, ref; if (this.projects.length) { - _print(_safe('\n ')); + __out.push('\n '); ref = this.projects; for (i = 0, len = ref.length; i < len; i++) { project = ref[i]; - _print(_safe('\n ')); - _print(project.name); - _print(_safe('\n

')); - _print(project.description); - _print(_safe('

\n ')); + __out.push('\n '); + __out.push(__sanitize(project.name)); + __out.push('\n

'); + __out.push(__sanitize(project.description)); + __out.push('

\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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} diff --git a/tests/expected/noJstGlobalCheckTest/all.js b/tests/expected/noJstGlobalCheckTest/all.js index f51aa69..07839a3 100644 --- a/tests/expected/noJstGlobalCheckTest/all.js +++ b/tests/expected/noJstGlobalCheckTest/all.js @@ -1,150 +1,168 @@ window.JST["tests/fixtures/advanced-example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (function() { (function() { var i, len, project, ref; if (this.projects.length) { - _print(_safe('\n ')); + __out.push('\n '); ref = this.projects; for (i = 0, len = ref.length; i < len; i++) { project = ref[i]; - _print(_safe('\n ')); - _print(project.name); - _print(_safe('\n

')); - _print(project.description); - _print(_safe('

\n ')); + __out.push('\n '); + __out.push(__sanitize(project.name)); + __out.push('\n

'); + __out.push(__sanitize(project.description)); + __out.push('

\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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} window.JST["tests/fixtures/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} window.JST["tests/fixtures/nested/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} diff --git a/tests/expected/srcDestTest/all.js b/tests/expected/srcDestTest/all.js index a43cd15..20453d2 100644 --- a/tests/expected/srcDestTest/all.js +++ b/tests/expected/srcDestTest/all.js @@ -2,158 +2,176 @@ if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/advanced-example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (function() { (function() { var i, len, project, ref; if (this.projects.length) { - _print(_safe('\n ')); + __out.push('\n '); ref = this.projects; for (i = 0, len = ref.length; i < len; i++) { project = ref[i]; - _print(_safe('\n ')); - _print(project.name); - _print(_safe('\n

')); - _print(project.description); - _print(_safe('

\n ')); + __out.push('\n '); + __out.push(__sanitize(project.name)); + __out.push('\n

'); + __out.push(__sanitize(project.description)); + __out.push('

\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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} if (!window.JST) { window.JST = {}; } window.JST["tests/fixtures/nested/example"] = function(__obj) { - var _safe = function(value) { - if (typeof value === 'undefined' && value == null) - value = ''; - var result = new String(value); - result.ecoSafe = true; - return result; + 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) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); }; + } + (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, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - }, - safe: _safe - }, key; - for (key in __obj) obj[key] = __obj[key]; - return obj; - })()); -}; + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +} From 676cdd9fb3774cfe9a0298da42643984813bb0fd Mon Sep 17 00:00:00 2001 From: cesine Date: Wed, 22 Jul 2020 11:41:59 -0400 Subject: [PATCH 4/5] reduce diff --- tasks/eco.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/eco.js b/tasks/eco.js index 15fa3e3..ea74226 100644 --- a/tasks/eco.js +++ b/tasks/eco.js @@ -35,7 +35,7 @@ module.exports = function(grunt) { } try { - output = ' = ' + eco.compile(grunt.file.read(src)).toString(); + output = ' = ' + eco.compile(grunt.file.read(src)); grunt.log.debug('output', output); } catch (e) { grunt.log.error("Error in " + src + ":\n" + e); From 28b7489eb1bcf323f8b3712f69d60a1f28a498b0 Mon Sep 17 00:00:00 2001 From: cesine Date: Wed, 22 Jul 2020 11:48:56 -0400 Subject: [PATCH 5/5] add node 10 in travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 518f95b..dd46521 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ node_js: - '0.12' - 6 - 8 + - 10 - 12 script: