diff --git a/.editorconfig b/.editorconfig index b9d48d491..d69dc778c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,6 +5,9 @@ indent_size = 2 insert_final_newline = true trim_trailing_whitespace = true +[spec/expected/*.js] +insert_final_newline = false + [*.yml] indent_size = 2 insert_final_newline = true diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index 7762412ef..8f437cda4 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -308,7 +308,7 @@ JavaScriptCompiler.prototype = { if (appendOnly) { if (bufferStart) { - bufferStart.prepend('return '); + bufferStart.prepend('return ""+'); bufferEnd.add(';'); } else if (!sourceSeen) { this.source.push('return "";'); diff --git a/package-lock.json b/package-lock.json index 325c28e09..cfc881c36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "handlebars", - "version": "4.7.7", + "version": "4.7.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "handlebars", - "version": "4.7.7", + "version": "4.7.8", "license": "MIT", "dependencies": { "minimist": "^1.2.5", @@ -24,7 +24,6 @@ "babel-runtime": "^5.1.10", "benchmark": "~1.0", "chai": "^4.2.0", - "chai-diff": "^1.0.1", "concurrently": "^5.0.0", "dirty-chai": "^2.0.1", "dtslint": "^0.5.5", @@ -2700,18 +2699,6 @@ "node": ">=4" } }, - "node_modules/chai-diff": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/chai-diff/-/chai-diff-1.0.1.tgz", - "integrity": "sha1-bGaJRwDYDNkDUKtORANiXU9TocE=", - "dev": true, - "dependencies": { - "diff": "^2.2.1" - }, - "peerDependencies": { - "chai": ">= 3.0" - } - }, "node_modules/chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -4127,15 +4114,6 @@ "node": ">=0.4.0" } }, - "node_modules/diff": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz", - "integrity": "sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k=", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/diff-sequences": { "version": "27.4.0", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.4.0.tgz", @@ -17452,15 +17430,6 @@ "type-detect": "^4.0.5" } }, - "chai-diff": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/chai-diff/-/chai-diff-1.0.1.tgz", - "integrity": "sha1-bGaJRwDYDNkDUKtORANiXU9TocE=", - "dev": true, - "requires": { - "diff": "^2.2.1" - } - }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -18606,12 +18575,6 @@ } } }, - "diff": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz", - "integrity": "sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k=", - "dev": true - }, "diff-sequences": { "version": "27.4.0", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.4.0.tgz", diff --git a/package.json b/package.json index 463c01dac..e7e3126de 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "babel-runtime": "^5.1.10", "benchmark": "~1.0", "chai": "^4.2.0", - "chai-diff": "^1.0.1", "concurrently": "^5.0.0", "dirty-chai": "^2.0.1", "dtslint": "^0.5.5", diff --git a/spec/expected/bom.amd.js b/spec/expected/bom.amd.js index 906989feb..38842be40 100644 --- a/spec/expected/bom.amd.js +++ b/spec/expected/bom.amd.js @@ -1,6 +1,6 @@ define(['handlebars.runtime'], function(Handlebars) { - Handlebars = Handlebars["default"]; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; - return templates['bom'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { - return "a"; - },"useData":true}); - }); \ No newline at end of file + Handlebars = Handlebars["default"]; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; +return templates['bom'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { + return "a"; +},"useData":true}); +}); \ No newline at end of file diff --git a/spec/expected/empty.amd.simple.js b/spec/expected/empty.amd.simple.js index b4014bb83..7b2bb3163 100644 --- a/spec/expected/empty.amd.simple.js +++ b/spec/expected/empty.amd.simple.js @@ -1,3 +1,3 @@ {"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { - return ""; -},"useData":true} \ No newline at end of file + return ""; +},"useData":true} diff --git a/spec/expected/handlebar.path.amd.js b/spec/expected/handlebar.path.amd.js index b3aa1f08a..72a95ffb6 100644 --- a/spec/expected/handlebar.path.amd.js +++ b/spec/expected/handlebar.path.amd.js @@ -1,6 +1,6 @@ define(['some-path/handlebars.runtime'], function(Handlebars) { - Handlebars = Handlebars["default"]; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; - return templates['empty'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { - return ""; - },"useData":true}); - }); \ No newline at end of file + Handlebars = Handlebars["default"]; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; +return templates['empty'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { + return ""; +},"useData":true}); +}); \ No newline at end of file diff --git a/spec/expected/help.menu.txt b/spec/expected/help.menu.txt index 834f4afe2..35e566e37 100644 --- a/spec/expected/help.menu.txt +++ b/spec/expected/help.menu.txt @@ -1,6 +1,5 @@ Precompile handlebar templates. Usage: handlebars [template|directory]... - Options: -f, --output Output File [string] --map Source Map File [string] @@ -22,4 +21,4 @@ Options: -e, --extension Template extension. [string] [default: "handlebars"] -b, --bom Removes the BOM (Byte Order Mark) from the beginning of the templates. [boolean] -v, --version Prints the current compiler version [boolean] - --help Outputs this message [boolean] \ No newline at end of file + --help Outputs this message [boolean] diff --git a/spec/expected/namespace.amd.js b/spec/expected/namespace.amd.js index cdd91f0df..662baaaad 100644 --- a/spec/expected/namespace.amd.js +++ b/spec/expected/namespace.amd.js @@ -1,10 +1,10 @@ define(['handlebars.runtime'], function(Handlebars) { - Handlebars = Handlebars["default"]; var template = Handlebars.template, templates = someNameSpace = someNameSpace || {}; - templates['empty'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { - return ""; - },"useData":true}); - templates['empty'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { - return ""; - },"useData":true}); - return templates; - }); \ No newline at end of file + Handlebars = Handlebars["default"]; var template = Handlebars.template, templates = someNameSpace = someNameSpace || {}; +templates['empty'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { + return ""; +},"useData":true}); +templates['empty'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { + return ""; +},"useData":true}); +return templates; +}); \ No newline at end of file diff --git a/spec/expected/non.default.extension.amd.js b/spec/expected/non.default.extension.amd.js index 264499a7c..84b1cfd1d 100644 --- a/spec/expected/non.default.extension.amd.js +++ b/spec/expected/non.default.extension.amd.js @@ -1,6 +1,6 @@ define(['handlebars.runtime'], function(Handlebars) { - Handlebars = Handlebars["default"]; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; - return templates['non.default.extension'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { - return "