diff --git a/CHANGELOG.md b/CHANGELOG.md index 331639b..f825238 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +v0.1.4 + Upgraded dependencies v0.1.3 Support for function name within dynamic mappings v0.1.2 @@ -5,4 +7,4 @@ v0.1.2 v0.1.1 Use of initial compile options v0.1.0 - Initial release. + Initial release diff --git a/package.json b/package.json index 0f5e84c..59888e2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grunt-fest", "description": "Compile Fest templates", - "version": "0.1.3", + "version": "0.1.4", "homepage": "https://github.com/eprev/grunt-fest", "author": { "name": "Anton Eprev", @@ -25,12 +25,14 @@ "scripts": { "test": "grunt test" }, + "dependencies": { + "fest": "0.8.0" + }, "devDependencies": { - "grunt-contrib-jshint": "~0.1.1", - "grunt-contrib-clean": "~0.4.0", - "grunt-contrib-nodeunit": "~0.1.2", - "grunt": "~0.4.0", - "fest": "~0.5.4" + "grunt-contrib-jshint": "0.7.2", + "grunt-contrib-clean": "0.5.0", + "grunt-contrib-nodeunit": "0.2.2", + "grunt": "0.4.2" }, "peerDependencies": { "grunt": "~0.4.0" diff --git a/test/expected/fixtures/qux/bar/baz.js b/test/expected/fixtures/qux/bar/baz.js index 7d7a15b..5d35997 100644 --- a/test/expected/fixtures/qux/bar/baz.js +++ b/test/expected/fixtures/qux/bar/baz.js @@ -10,6 +10,7 @@ function(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/expected/fixtures/qux/bar/baz.xml.js b/test/expected/fixtures/qux/bar/baz.xml.js index 7d7a15b..5d35997 100644 --- a/test/expected/fixtures/qux/bar/baz.xml.js +++ b/test/expected/fixtures/qux/bar/baz.xml.js @@ -10,6 +10,7 @@ function(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/expected/fixtures/qux/foo.js b/test/expected/fixtures/qux/foo.js index bbf855a..78cc1e4 100644 --- a/test/expected/fixtures/qux/foo.js +++ b/test/expected/fixtures/qux/foo.js @@ -10,6 +10,7 @@ function(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/expected/fixtures/qux/foo.xml.js b/test/expected/fixtures/qux/foo.xml.js index bbf855a..78cc1e4 100644 --- a/test/expected/fixtures/qux/foo.xml.js +++ b/test/expected/fixtures/qux/foo.xml.js @@ -10,6 +10,7 @@ function(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/expected/tmp/dynamic-compiled/qux/bar/baz.js b/test/expected/tmp/dynamic-compiled/qux/bar/baz.js index 0d74b3a..1f3e9f4 100644 --- a/test/expected/tmp/dynamic-compiled/qux/bar/baz.js +++ b/test/expected/tmp/dynamic-compiled/qux/bar/baz.js @@ -1 +1 @@ -define("qux/bar/baz.js", function () { return function (__fest_context){"use strict";var __fest_self=this,__fest_buf="",__fest_chunks=[],__fest_chunk,__fest_attrs=[],__fest_select,__fest_if,__fest_iterator,__fest_to,__fest_fn,__fest_html="",__fest_blocks={},__fest_params,__fest_element,__fest_debug_file="",__fest_debug_line="",__fest_debug_block="",__fest_htmlchars=/[&<>"]/g,__fest_short_tags = {"area":true,"base":true,"br":true,"col":true,"command":true,"embed":true,"hr":true,"img":true,"input":true,"keygen":true,"link":true,"meta":true,"param":true,"source":true,"wbr":true},__fest_element_stack = [],__fest_htmlhash={"&":"&","<":"<",">":">","\"":"""},__fest_jschars=/[\\'"\/\n\r\t\b\f<>]/g,__fest_jshash={"\"":"\\\"","\\":"\\\\","/":"\\/","\n":"\\n","\r":"\\r","\t":"\\t","\b":"\\b","\f":"\\f","'":"\\'","<":"\\u003C",">":"\\u003E"},___fest_log_error;if(typeof __fest_error === "undefined"){___fest_log_error = (typeof console !== "undefined" && console.error) ? function(){return Function.prototype.apply.call(console.error, console, arguments)} : function(){};}else{___fest_log_error=__fest_error};function __fest_log_error(msg){___fest_log_error(msg+"\nin block \""+__fest_debug_block+"\" at line: "+__fest_debug_line+"\nfile: "+__fest_debug_file)}function __fest_replaceHTML(chr){return __fest_htmlhash[chr]}function __fest_replaceJS(chr){return __fest_jshash[chr]}function __fest_extend(dest, src){for(var i in src)if(src.hasOwnProperty(i))dest[i]=src[i];}function __fest_param(fn){fn.param=true;return fn}function __fest_call(fn, params,cp){if(cp)for(var i in params)if(typeof params[i]=="function"&¶ms[i].param)params[i]=params[i]();return fn.call(__fest_self,params)}function __fest_escapeJS(s){if (typeof s==="string") {if (__fest_jschars.test(s))return s.replace(__fest_jschars,__fest_replaceJS);} else if (typeof s==="undefined")return "";return s;}function __fest_escapeHTML(s){if (typeof s==="string") {if (__fest_htmlchars.test(s))return s.replace(__fest_htmlchars,__fest_replaceHTML);} else if (typeof s==="undefined")return "";return s;}__fest_select="block";__fest_params={};try{__fest_params=Grunt}catch(e){__fest_log_error(e.message)}__fest_chunks.push(__fest_buf,{name:__fest_select,params:__fest_params,cp:false});__fest_buf="";__fest_blocks.block=function(params){var __fest_buf="";__fest_buf+=("Hello, ");try{__fest_buf+=(__fest_escapeHTML(params))}catch(e){__fest_log_error(e.message + "3");}__fest_buf+=("!");return __fest_buf;};__fest_to=__fest_chunks.length;if (__fest_to) {__fest_iterator = 0;for (;__fest_iterator<__fest_to;__fest_iterator++) {__fest_chunk=__fest_chunks[__fest_iterator];if (typeof __fest_chunk==="string") {__fest_html+=__fest_chunk;} else {__fest_fn=__fest_blocks[__fest_chunk.name];if (__fest_fn) __fest_html+=__fest_call(__fest_fn,__fest_chunk.params,__fest_chunk.cp);}}return __fest_html+__fest_buf;} else {return __fest_buf;}} ; }); \ No newline at end of file +define("qux/bar/baz.js", function () { return function (__fest_context){"use strict";var __fest_self=this,__fest_buf="",__fest_chunks=[],__fest_chunk,__fest_attrs=[],__fest_select,__fest_if,__fest_iterator,__fest_to,__fest_fn,__fest_html="",__fest_blocks={},__fest_params,__fest_element,__fest_debug_file="",__fest_debug_line="",__fest_debug_block="",__fest_htmlchars=/[&<>"]/g,__fest_htmlchars_test=/[&<>"]/,__fest_short_tags = {"area":true,"base":true,"br":true,"col":true,"command":true,"embed":true,"hr":true,"img":true,"input":true,"keygen":true,"link":true,"meta":true,"param":true,"source":true,"wbr":true},__fest_element_stack = [],__fest_htmlhash={"&":"&","<":"<",">":">","\"":"""},__fest_jschars=/[\\'"\/\n\r\t\b\f<>]/g,__fest_jschars_test=/[\\'"\/\n\r\t\b\f<>]/,__fest_jshash={"\"":"\\\"","\\":"\\\\","/":"\\/","\n":"\\n","\r":"\\r","\t":"\\t","\b":"\\b","\f":"\\f","'":"\\'","<":"\\u003C",">":"\\u003E"},___fest_log_error;if(typeof __fest_error === "undefined"){___fest_log_error = (typeof console !== "undefined" && console.error) ? function(){return Function.prototype.apply.call(console.error, console, arguments)} : function(){};}else{___fest_log_error=__fest_error};function __fest_log_error(msg){___fest_log_error(msg+"\nin block \""+__fest_debug_block+"\" at line: "+__fest_debug_line+"\nfile: "+__fest_debug_file)}function __fest_replaceHTML(chr){return __fest_htmlhash[chr]}function __fest_replaceJS(chr){return __fest_jshash[chr]}function __fest_extend(dest, src){for(var i in src)if(src.hasOwnProperty(i))dest[i]=src[i];}function __fest_param(fn){fn.param=true;return fn}function __fest_call(fn, params,cp){if(cp)for(var i in params)if(typeof params[i]=="function"&¶ms[i].param)params[i]=params[i]();return fn.call(__fest_self,params)}function __fest_escapeJS(s){if (typeof s==="string") {if (__fest_jschars_test.test(s))return s.replace(__fest_jschars,__fest_replaceJS);} else if (typeof s==="undefined")return "";return s;}function __fest_escapeHTML(s){if (typeof s==="string") {if (__fest_htmlchars_test.test(s))return s.replace(__fest_htmlchars,__fest_replaceHTML);} else if (typeof s==="undefined")return "";return s;}__fest_select="block";__fest_params={};try{__fest_params=Grunt}catch(e){__fest_log_error(e.message)}__fest_chunks.push(__fest_buf,{name:__fest_select,params:__fest_params,cp:false});__fest_buf="";__fest_blocks.block=function(params){var __fest_buf="";__fest_buf+=("Hello, ");try{__fest_buf+=(__fest_escapeHTML(params))}catch(e){__fest_log_error(e.message + "3");}__fest_buf+=("!");return __fest_buf;};__fest_to=__fest_chunks.length;if (__fest_to) {__fest_iterator = 0;for (;__fest_iterator<__fest_to;__fest_iterator++) {__fest_chunk=__fest_chunks[__fest_iterator];if (typeof __fest_chunk==="string") {__fest_html+=__fest_chunk;} else {__fest_fn=__fest_blocks[__fest_chunk.name];if (__fest_fn) __fest_html+=__fest_call(__fest_fn,__fest_chunk.params,__fest_chunk.cp);}}return __fest_html+__fest_buf;} else {return __fest_buf;}} ; }); \ No newline at end of file diff --git a/test/expected/tmp/dynamic-compiled/qux/foo.js b/test/expected/tmp/dynamic-compiled/qux/foo.js index 684dbf1..c7c0718 100644 --- a/test/expected/tmp/dynamic-compiled/qux/foo.js +++ b/test/expected/tmp/dynamic-compiled/qux/foo.js @@ -1 +1 @@ -define("qux/foo.js", function () { return function (__fest_context){"use strict";var __fest_self=this,__fest_buf="",__fest_chunks=[],__fest_chunk,__fest_attrs=[],__fest_select,__fest_if,__fest_iterator,__fest_to,__fest_fn,__fest_html="",__fest_blocks={},__fest_params,__fest_element,__fest_debug_file="",__fest_debug_line="",__fest_debug_block="",__fest_htmlchars=/[&<>"]/g,__fest_short_tags = {"area":true,"base":true,"br":true,"col":true,"command":true,"embed":true,"hr":true,"img":true,"input":true,"keygen":true,"link":true,"meta":true,"param":true,"source":true,"wbr":true},__fest_element_stack = [],__fest_htmlhash={"&":"&","<":"<",">":">","\"":"""},__fest_jschars=/[\\'"\/\n\r\t\b\f<>]/g,__fest_jshash={"\"":"\\\"","\\":"\\\\","/":"\\/","\n":"\\n","\r":"\\r","\t":"\\t","\b":"\\b","\f":"\\f","'":"\\'","<":"\\u003C",">":"\\u003E"},___fest_log_error;if(typeof __fest_error === "undefined"){___fest_log_error = (typeof console !== "undefined" && console.error) ? function(){return Function.prototype.apply.call(console.error, console, arguments)} : function(){};}else{___fest_log_error=__fest_error};function __fest_log_error(msg){___fest_log_error(msg+"\nin block \""+__fest_debug_block+"\" at line: "+__fest_debug_line+"\nfile: "+__fest_debug_file)}function __fest_replaceHTML(chr){return __fest_htmlhash[chr]}function __fest_replaceJS(chr){return __fest_jshash[chr]}function __fest_extend(dest, src){for(var i in src)if(src.hasOwnProperty(i))dest[i]=src[i];}function __fest_param(fn){fn.param=true;return fn}function __fest_call(fn, params,cp){if(cp)for(var i in params)if(typeof params[i]=="function"&¶ms[i].param)params[i]=params[i]();return fn.call(__fest_self,params)}function __fest_escapeJS(s){if (typeof s==="string") {if (__fest_jschars.test(s))return s.replace(__fest_jschars,__fest_replaceJS);} else if (typeof s==="undefined")return "";return s;}function __fest_escapeHTML(s){if (typeof s==="string") {if (__fest_htmlchars.test(s))return s.replace(__fest_htmlchars,__fest_replaceHTML);} else if (typeof s==="undefined")return "";return s;}__fest_buf+=("Test");__fest_to=__fest_chunks.length;if (__fest_to) {__fest_iterator = 0;for (;__fest_iterator<__fest_to;__fest_iterator++) {__fest_chunk=__fest_chunks[__fest_iterator];if (typeof __fest_chunk==="string") {__fest_html+=__fest_chunk;} else {__fest_fn=__fest_blocks[__fest_chunk.name];if (__fest_fn) __fest_html+=__fest_call(__fest_fn,__fest_chunk.params,__fest_chunk.cp);}}return __fest_html+__fest_buf;} else {return __fest_buf;}} ; }); \ No newline at end of file +define("qux/foo.js", function () { return function (__fest_context){"use strict";var __fest_self=this,__fest_buf="",__fest_chunks=[],__fest_chunk,__fest_attrs=[],__fest_select,__fest_if,__fest_iterator,__fest_to,__fest_fn,__fest_html="",__fest_blocks={},__fest_params,__fest_element,__fest_debug_file="",__fest_debug_line="",__fest_debug_block="",__fest_htmlchars=/[&<>"]/g,__fest_htmlchars_test=/[&<>"]/,__fest_short_tags = {"area":true,"base":true,"br":true,"col":true,"command":true,"embed":true,"hr":true,"img":true,"input":true,"keygen":true,"link":true,"meta":true,"param":true,"source":true,"wbr":true},__fest_element_stack = [],__fest_htmlhash={"&":"&","<":"<",">":">","\"":"""},__fest_jschars=/[\\'"\/\n\r\t\b\f<>]/g,__fest_jschars_test=/[\\'"\/\n\r\t\b\f<>]/,__fest_jshash={"\"":"\\\"","\\":"\\\\","/":"\\/","\n":"\\n","\r":"\\r","\t":"\\t","\b":"\\b","\f":"\\f","'":"\\'","<":"\\u003C",">":"\\u003E"},___fest_log_error;if(typeof __fest_error === "undefined"){___fest_log_error = (typeof console !== "undefined" && console.error) ? function(){return Function.prototype.apply.call(console.error, console, arguments)} : function(){};}else{___fest_log_error=__fest_error};function __fest_log_error(msg){___fest_log_error(msg+"\nin block \""+__fest_debug_block+"\" at line: "+__fest_debug_line+"\nfile: "+__fest_debug_file)}function __fest_replaceHTML(chr){return __fest_htmlhash[chr]}function __fest_replaceJS(chr){return __fest_jshash[chr]}function __fest_extend(dest, src){for(var i in src)if(src.hasOwnProperty(i))dest[i]=src[i];}function __fest_param(fn){fn.param=true;return fn}function __fest_call(fn, params,cp){if(cp)for(var i in params)if(typeof params[i]=="function"&¶ms[i].param)params[i]=params[i]();return fn.call(__fest_self,params)}function __fest_escapeJS(s){if (typeof s==="string") {if (__fest_jschars_test.test(s))return s.replace(__fest_jschars,__fest_replaceJS);} else if (typeof s==="undefined")return "";return s;}function __fest_escapeHTML(s){if (typeof s==="string") {if (__fest_htmlchars_test.test(s))return s.replace(__fest_htmlchars,__fest_replaceHTML);} else if (typeof s==="undefined")return "";return s;}__fest_buf+=("Test");__fest_to=__fest_chunks.length;if (__fest_to) {__fest_iterator = 0;for (;__fest_iterator<__fest_to;__fest_iterator++) {__fest_chunk=__fest_chunks[__fest_iterator];if (typeof __fest_chunk==="string") {__fest_html+=__fest_chunk;} else {__fest_fn=__fest_blocks[__fest_chunk.name];if (__fest_fn) __fest_html+=__fest_call(__fest_fn,__fest_chunk.params,__fest_chunk.cp);}}return __fest_html+__fest_buf;} else {return __fest_buf;}} ; }); \ No newline at end of file diff --git a/test/expected/tmp/dynamic-named/test/fixtures/qux/bar/baz.js b/test/expected/tmp/dynamic-named/test/fixtures/qux/bar/baz.js index 5451436..06fa464 100644 --- a/test/expected/tmp/dynamic-named/test/fixtures/qux/bar/baz.js +++ b/test/expected/tmp/dynamic-named/test/fixtures/qux/bar/baz.js @@ -10,6 +10,7 @@ function baz(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function baz(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function baz(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/expected/tmp/dynamic-named/test/fixtures/qux/foo.js b/test/expected/tmp/dynamic-named/test/fixtures/qux/foo.js index 2ab03a5..2cde19c 100644 --- a/test/expected/tmp/dynamic-named/test/fixtures/qux/foo.js +++ b/test/expected/tmp/dynamic-named/test/fixtures/qux/foo.js @@ -10,6 +10,7 @@ function foo(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function foo(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function foo(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/expected/tmp/dynamic/test/fixtures/qux/bar/baz.js b/test/expected/tmp/dynamic/test/fixtures/qux/bar/baz.js index 7d7a15b..5d35997 100644 --- a/test/expected/tmp/dynamic/test/fixtures/qux/bar/baz.js +++ b/test/expected/tmp/dynamic/test/fixtures/qux/bar/baz.js @@ -10,6 +10,7 @@ function(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/expected/tmp/dynamic/test/fixtures/qux/foo.js b/test/expected/tmp/dynamic/test/fixtures/qux/foo.js index bbf855a..78cc1e4 100644 --- a/test/expected/tmp/dynamic/test/fixtures/qux/foo.js +++ b/test/expected/tmp/dynamic/test/fixtures/qux/foo.js @@ -10,6 +10,7 @@ function(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/expected/tmp/named/foo.js b/test/expected/tmp/named/foo.js index 2ab03a5..2cde19c 100644 --- a/test/expected/tmp/named/foo.js +++ b/test/expected/tmp/named/foo.js @@ -10,6 +10,7 @@ function foo(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function foo(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function foo(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/expected/tmp/test/fixtures/qux/bar/baz.js b/test/expected/tmp/test/fixtures/qux/bar/baz.js index 7d7a15b..5d35997 100644 --- a/test/expected/tmp/test/fixtures/qux/bar/baz.js +++ b/test/expected/tmp/test/fixtures/qux/bar/baz.js @@ -10,6 +10,7 @@ function(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/expected/tmp/test/fixtures/qux/foo.js b/test/expected/tmp/test/fixtures/qux/foo.js index bbf855a..78cc1e4 100644 --- a/test/expected/tmp/test/fixtures/qux/foo.js +++ b/test/expected/tmp/test/fixtures/qux/foo.js @@ -10,6 +10,7 @@ function(__fest_context) { __fest_debug_line = "", __fest_debug_block = "", __fest_htmlchars = /[&<>"]/g, + __fest_htmlchars_test = /[&<>"]/, __fest_short_tags = { "area": true, "base": true, @@ -35,6 +36,7 @@ function(__fest_context) { "\"": """ }, __fest_jschars = /[\\'"\/\n\r\t\b\f<>]/g, + __fest_jschars_test = /[\\'"\/\n\r\t\b\f<>]/, __fest_jshash = { "\"": "\\\"", "\\": "\\\\", @@ -80,13 +82,13 @@ function(__fest_context) { } function __fest_escapeJS(s) { if (typeof s === "string") { - if (__fest_jschars.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); + if (__fest_jschars_test.test(s)) return s.replace(__fest_jschars, __fest_replaceJS); } else if (typeof s === "undefined") return ""; return s; } function __fest_escapeHTML(s) { if (typeof s === "string") { - if (__fest_htmlchars.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); + if (__fest_htmlchars_test.test(s)) return s.replace(__fest_htmlchars, __fest_replaceHTML); } else if (typeof s === "undefined") return ""; return s; } diff --git a/test/fest_test.js b/test/fest_test.js index a0bd979..d3c6450 100644 --- a/test/fest_test.js +++ b/test/fest_test.js @@ -29,57 +29,71 @@ exports.bem = { }, put_in_the_same_derictory: function (test) { this.templates.forEach(function (tpl) { - var actual = grunt.file.read('test/expected/fixtures/' + tpl + '.js'); - var expected = grunt.file.read('test/fixtures/' + tpl + '.js'); - test.equal(actual, expected); + var actualFn = 'test/expected/fixtures/' + tpl + '.js', + expectedFn = 'test/fixtures/' + tpl + '.js', + actual = grunt.file.read(actualFn), + expected = grunt.file.read(expectedFn); + test.equal(actual, expected, actualFn + ' != ' + expectedFn); }); test.done(); }, put_in_the_same_derictory_and_append_ext: function (test) { this.templates.forEach(function (tpl) { - var actual = grunt.file.read('test/expected/fixtures/' + tpl + '.xml.js'); - var expected = grunt.file.read('test/fixtures/' + tpl + '.xml.js'); - test.equal(actual, expected); + var actualFn = 'test/expected/fixtures/' + tpl + '.xml.js', + expectedFn = 'test/fixtures/' + tpl + '.xml.js', + actual = grunt.file.read(actualFn), + expected = grunt.file.read(expectedFn); + test.equal(actual, expected, actualFn + ' != ' + expectedFn); }); test.done(); }, 'test/tmp': function (test) { this.templates.forEach(function (tpl) { - var actual = grunt.file.read('test/tmp/test/fixtures/' + tpl + '.js'); - var expected = grunt.file.read('test/expected/tmp/test/fixtures/' + tpl + '.js'); - test.equal(actual, expected); + var actualFn = 'test/tmp/test/fixtures/' + tpl + '.js', + expectedFn = 'test/expected/tmp/test/fixtures/' + tpl + '.js', + actual = grunt.file.read(actualFn), + expected = grunt.file.read(expectedFn); + test.equal(actual, expected, actualFn + ' != ' + expectedFn); }); test.done(); }, dynamic_expansion: function (test) { this.templates.forEach(function (tpl) { - var actual = grunt.file.read('test/tmp/dynamic/test/fixtures/' + tpl + '.js'); - var expected = grunt.file.read('test/expected/tmp/dynamic/test/fixtures/' + tpl + '.js'); - test.equal(actual, expected); + var actualFn = 'test/tmp/dynamic/test/fixtures/' + tpl + '.js', + expectedFn = 'test/expected/tmp/dynamic/test/fixtures/' + tpl + '.js', + actual = grunt.file.read(actualFn), + expected = grunt.file.read(expectedFn); + test.equal(actual, expected, actualFn + ' != ' + expectedFn); }); test.done(); }, dynamic_expansion_with_cwd_and_template: function (test) { this.templates.forEach(function (tpl) { - var actual = grunt.file.read('test/tmp/dynamic-compiled/' + tpl + '.js'); - var expected = grunt.file.read('test/expected/tmp/dynamic-compiled/' + tpl + '.js'); - test.equal(actual, expected); + var actualFn = 'test/tmp/dynamic-compiled/' + tpl + '.js', + expectedFn = 'test/expected/tmp/dynamic-compiled/' + tpl + '.js', + actual = grunt.file.read(actualFn), + expected = grunt.file.read(expectedFn); + test.equal(actual, expected, actualFn + ' != ' + expectedFn); }); test.done(); }, named_function: function (test) { ['foo'].forEach(function (tpl) { - var actual = grunt.file.read('test/tmp/named/' + tpl + '.js'); - var expected = grunt.file.read('test/expected/tmp/named/' + tpl + '.js'); - test.equal(actual, expected); + var actualFn = 'test/tmp/named/' + tpl + '.js', + expectedFn = 'test/expected/tmp/named/' + tpl + '.js', + actual = grunt.file.read(actualFn), + expected = grunt.file.read(expectedFn); + test.equal(actual, expected, actualFn + ' != ' + expectedFn); }); test.done(); }, named_function_within_dynamic_expansion: function (test) { this.templates.forEach(function (tpl) { - var actual = grunt.file.read('test/tmp/dynamic-named/test/fixtures/' + tpl + '.js'); - var expected = grunt.file.read('test/expected/tmp/dynamic-named/test/fixtures/' + tpl + '.js'); - test.equal(actual, expected); + var actualFn = 'test/tmp/dynamic-named/test/fixtures/' + tpl + '.js', + expectedFn = 'test/expected/tmp/dynamic-named/test/fixtures/' + tpl + '.js', + actual = grunt.file.read(actualFn), + expected = grunt.file.read(expectedFn); + test.equal(actual, expected, actualFn + ' != ' + expectedFn); }); test.done(); }