vendor/assets/javascripts/handlebars.runtime.js in handlebars_assets-0.12.3 vs vendor/assets/javascripts/handlebars.runtime.js in handlebars_assets-0.13.0

- old
+ new

@@ -27,17 +27,18 @@ (function(Handlebars, undefined) { ; // lib/handlebars/base.js -Handlebars.VERSION = "1.0.0-rc.4"; -Handlebars.COMPILER_REVISION = 3; +Handlebars.VERSION = "1.0.0"; +Handlebars.COMPILER_REVISION = 4; Handlebars.REVISION_CHANGES = { 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it 2: '== 1.0.0-rc.3', - 3: '>= 1.0.0-rc.4' + 3: '== 1.0.0-rc.4', + 4: '>= 1.0.0' }; Handlebars.helpers = {}; Handlebars.partials = {}; @@ -65,11 +66,11 @@ Handlebars.registerHelper('helperMissing', function(arg) { if(arguments.length === 2) { return undefined; } else { - throw new Error("Could not find property '" + arg + "'"); + throw new Error("Missing helper: '" + arg + "'"); } }); Handlebars.registerHelper('blockHelperMissing', function(context, options) { var inverse = options.inverse || function() {}, fn = options.fn; @@ -122,10 +123,13 @@ Handlebars.registerHelper('each', function(context, options) { var fn = options.fn, inverse = options.inverse; var i = 0, ret = "", data; + var type = toString.call(context); + if(type === functionType) { context = context.call(this); } + if (options.data) { data = Handlebars.createFrame(options.data); } if(context && typeof context === 'object') { @@ -150,26 +154,29 @@ } return ret; }); -Handlebars.registerHelper('if', function(context, options) { - var type = toString.call(context); - if(type === functionType) { context = context.call(this); } +Handlebars.registerHelper('if', function(conditional, options) { + var type = toString.call(conditional); + if(type === functionType) { conditional = conditional.call(this); } - if(!context || Handlebars.Utils.isEmpty(context)) { + if(!conditional || Handlebars.Utils.isEmpty(conditional)) { return options.inverse(this); } else { return options.fn(this); } }); -Handlebars.registerHelper('unless', function(context, options) { - return Handlebars.helpers['if'].call(this, context, {fn: options.inverse, inverse: options.fn}); +Handlebars.registerHelper('unless', function(conditional, options) { + return Handlebars.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn}); }); Handlebars.registerHelper('with', function(context, options) { + var type = toString.call(context); + if(type === functionType) { context = context.call(this); } + if (!Handlebars.Utils.isEmpty(context)) return options.fn(context); }); Handlebars.registerHelper('log', function(context, options) { var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1; @@ -266,9 +273,19 @@ programWrapper = Handlebars.VM.program(i, fn, data); } else if (!programWrapper) { programWrapper = this.programs[i] = Handlebars.VM.program(i, fn); } return programWrapper; + }, + merge: function(param, common) { + var ret = param || common; + + if (param && common) { + ret = {}; + Handlebars.Utils.extend(ret, common); + Handlebars.Utils.extend(ret, param); + } + return ret; }, programWithDepth: Handlebars.VM.programWithDepth, noop: Handlebars.VM.noop, compilerInfo: null };