From c4192a46d261c8907e3096a43aa9014daf08964d Mon Sep 17 00:00:00 2001 From: Mateus Maso Date: Sun, 27 Apr 2014 20:05:19 -0400 Subject: [PATCH 1/4] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 10843ce..2cb1b6a 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ This library is an extension for Handlebars which allows nesting helpers or expr * Nesting helpers in one level deep. * Nesting expressions with helpers in one level deep. +## Dependencies + +* handlebars.js (>= 1.0) + ## Examples ```html From 757bf1196fce71749eae334729c9445b1933d380 Mon Sep 17 00:00:00 2001 From: Mateus Maso Date: Mon, 28 Apr 2014 00:58:08 -0400 Subject: [PATCH 2/4] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 2cb1b6a..79d8ad4 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,7 @@ This library is an extension for Handlebars which allows nesting helpers or expr ## Features -* Nesting helpers in one level deep. -* Nesting expressions with helpers in one level deep. +* Nesting helpers and expressions in one level deep. ## Dependencies From 34beba7ebc897a444e8fe051fea4ba4494f06351 Mon Sep 17 00:00:00 2001 From: Mateus Maso Date: Thu, 1 May 2014 22:51:57 -0400 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79d8ad4..39dd333 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ handlebars.nested ================= -This library is an extension for Handlebars which allows nesting helpers or expressions within other helpers in one level deep. It was first created as a workaround to older versions, but after more issues came across it turned out to be an effective solution for those problems. +This library is an extension for Handlebars which allows nesting helpers or expressions within other helpers in one level deep. It was first created as a workaround to older versions, but after more issues it turned out to be an effective solution for many problems. ## Features From 4e7aff4c1e5a2a2daff6a58e0860e43014a25b76 Mon Sep 17 00:00:00 2001 From: Mateus Maso Date: Sat, 10 May 2014 16:02:18 -0400 Subject: [PATCH 4/4] Update handlebars.nested.js --- lib/handlebars.nested.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/handlebars.nested.js b/lib/handlebars.nested.js index d6f897e..660117d 100644 --- a/lib/handlebars.nested.js +++ b/lib/handlebars.nested.js @@ -1,40 +1,35 @@ (function(Handlebars) { + var Utils = Handlebars.Utils; var registerHelper = Handlebars.registerHelper; - var isString = function(object) { + Handlebars.Utils.isString = function(object) { return toString.call(object) == '[object String]'; }; Handlebars.registerHelper = function(name, fn, inverse) { var nestedFn = function() { - var args = []; + var nestedArguments = []; for (var index = 0; index < arguments.length; index++) { var argument = arguments[index]; - if (argument && argument.hash) { - for (key in argument.hash) { - argument.hash[key] = Handlebars.resolveNested.apply(this, [argument.hash[key]]); - } - - args.push(argument); + if (argument && argument.hash) { + for (key in argument.hash) argument.hash[key] = Handlebars.resolveNested.apply(this, [argument.hash[key]]); + nestedArguments.push(argument); } else { - args.push(Handlebars.resolveNested.apply(this, [argument])); + nestedArguments.push(Handlebars.resolveNested.apply(this, [argument])); } } - return fn.apply(this, args); + return fn.apply(this, nestedArguments); }; registerHelper.apply(this, [name, nestedFn, inverse]); }; Handlebars.resolveNested = function(value) { - if (isString(value) && value.indexOf('{{') >= 0) { - value = Handlebars.compile(value)(this); - } - + if (Utils.isString(value) && value.indexOf('{{') >= 0) value = Handlebars.compile(value)(this); return value; };