From 4e7aff4c1e5a2a2daff6a58e0860e43014a25b76 Mon Sep 17 00:00:00 2001 From: Mateus Maso Date: Sat, 10 May 2014 16:02:18 -0400 Subject: [PATCH] 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; };