Skip to content

Commit

Permalink
Make argument length check compatible with Handlebars v3
Browse files Browse the repository at this point in the history
  • Loading branch information
emaphp committed Mar 3, 2016
1 parent 60dda07 commit 2f55ae0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ var strRepeat = function(str, times) {
module.exports = {
require: function(resourcePath) {
// Since Handlebars v4, an extra argument called "container" is passed to the helper wrapper.
// In order to keep compatibility, we remove the first argument from the list if we detect that more than 4 arguments are available.
// In order to keep compatibility, we remove the first argument from the list if we detect that more than 6 arguments are available.
// See issue #9 for details.
return "require(" + JSON.stringify(loaderUtils.urlToRequest(resourcePath)) + ").apply(null, Array.prototype.slice.call(arguments, arguments.length > 4))";
return "require(" + JSON.stringify(loaderUtils.urlToRequest(resourcePath)) + ").apply(null, Array.prototype.slice.call(arguments, arguments.length > 6))";
},

include: function(resourcePath) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "handlebars-template-loader",
"version": "0.5.6",
"version": "0.5.7",
"description": "A Handlebars template loader for Webpack",
"main": "index.js",
"homepage": "https://github.com/emaphp/handlebars-template-loader",
Expand Down
2 changes: 1 addition & 1 deletion test/templates/output/require.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = (Handlebars['default'] || Handlebars).template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "Hello, " + require("./bar.html").apply(null, Array.prototype.slice.call(arguments, arguments.length > 4)) + "\n";
return "Hello, " + require("./bar.html").apply(null, Array.prototype.slice.call(arguments, arguments.length > 6)) + "\n";
},"useData":true});

0 comments on commit 2f55ae0

Please sign in to comment.