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: 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", diff --git a/tasks/eco.js b/tasks/eco.js index 63fb484..ea74226 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)); + grunt.log.debug('output', output); } catch (e) { grunt.log.error("Error in " + src + ":\n" + e); grunt.fail.warn("Eco failed to compile " + src + "."); 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(''); +}