|
|
|
@ -29,24 +29,38 @@ var Handlebars = {};
|
|
|
|
|
;
|
|
|
|
|
// lib/handlebars/base.js
|
|
|
|
|
|
|
|
|
|
Handlebars.VERSION = "1.0.0-rc.3";
|
|
|
|
|
Handlebars.COMPILER_REVISION = 2;
|
|
|
|
|
Handlebars.VERSION = "1.0.0-rc.4";
|
|
|
|
|
Handlebars.COMPILER_REVISION = 3;
|
|
|
|
|
|
|
|
|
|
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'
|
|
|
|
|
2: '== 1.0.0-rc.3',
|
|
|
|
|
3: '>= 1.0.0-rc.4'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Handlebars.helpers = {};
|
|
|
|
|
Handlebars.partials = {};
|
|
|
|
|
|
|
|
|
|
var toString = Object.prototype.toString,
|
|
|
|
|
functionType = '[object Function]',
|
|
|
|
|
objectType = '[object Object]';
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper = function(name, fn, inverse) {
|
|
|
|
|
if (toString.call(name) === objectType) {
|
|
|
|
|
if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); }
|
|
|
|
|
Handlebars.Utils.extend(this.helpers, name);
|
|
|
|
|
} else {
|
|
|
|
|
if (inverse) { fn.not = inverse; }
|
|
|
|
|
this.helpers[name] = fn;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Handlebars.registerPartial = function(name, str) {
|
|
|
|
|
if (toString.call(name) === objectType) {
|
|
|
|
|
Handlebars.Utils.extend(this.partials, name);
|
|
|
|
|
} else {
|
|
|
|
|
this.partials[name] = str;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('helperMissing', function(arg) {
|
|
|
|
@ -57,8 +71,6 @@ var Handlebars = {};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var toString = Object.prototype.toString, functionType = "[object Function]";
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
|
|
|
|
|
var inverse = options.inverse || function() {}, fn = options.fn;
|
|
|
|
|
|
|
|
|
@ -203,6 +215,14 @@ var Handlebars = {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Handlebars.Utils = {
|
|
|
|
|
extend: function(obj, value) {
|
|
|
|
|
for(var key in value) {
|
|
|
|
|
if(value.hasOwnProperty(key)) {
|
|
|
|
|
obj[key] = value[key];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
escapeExpression: function(string) {
|
|
|
|
|
// don't escape SafeStrings, since they're already safe
|
|
|
|
|
if (string instanceof Handlebars.SafeString) {
|
|
|
|
@ -211,6 +231,11 @@ var Handlebars = {};
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Force a string conversion as this will be done by the append regardless and
|
|
|
|
|
// the regex test will do this transparently behind the scenes, causing issues if
|
|
|
|
|
// an object's to string has escaped characters in it.
|
|
|
|
|
string = string.toString();
|
|
|
|
|
|
|
|
|
|
if(!possible.test(string)) { return string; }
|
|
|
|
|
return string.replace(badChars, escapeChar);
|
|
|
|
|
},
|
|
|
|
@ -238,13 +263,11 @@ var Handlebars = {};
|
|
|
|
|
program: function(i, fn, data) {
|
|
|
|
|
var programWrapper = this.programs[i];
|
|
|
|
|
if(data) {
|
|
|
|
|
return Handlebars.VM.program(fn, data);
|
|
|
|
|
} else if(programWrapper) {
|
|
|
|
|
return programWrapper;
|
|
|
|
|
} else {
|
|
|
|
|
programWrapper = this.programs[i] = Handlebars.VM.program(fn);
|
|
|
|
|
return programWrapper;
|
|
|
|
|
programWrapper = Handlebars.VM.program(i, fn, data);
|
|
|
|
|
} else if (!programWrapper) {
|
|
|
|
|
programWrapper = this.programs[i] = Handlebars.VM.program(i, fn);
|
|
|
|
|
}
|
|
|
|
|
return programWrapper;
|
|
|
|
|
},
|
|
|
|
|
programWithDepth: Handlebars.VM.programWithDepth,
|
|
|
|
|
noop: Handlebars.VM.noop,
|
|
|
|
@ -276,21 +299,27 @@ var Handlebars = {};
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
programWithDepth: function(fn, data, $depth) {
|
|
|
|
|
var args = Array.prototype.slice.call(arguments, 2);
|
|
|
|
|
programWithDepth: function(i, fn, data /*, $depth */) {
|
|
|
|
|
var args = Array.prototype.slice.call(arguments, 3);
|
|
|
|
|
|
|
|
|
|
return function(context, options) {
|
|
|
|
|
var program = function(context, options) {
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
|
return fn.apply(this, [context, options.data || data].concat(args));
|
|
|
|
|
};
|
|
|
|
|
program.program = i;
|
|
|
|
|
program.depth = args.length;
|
|
|
|
|
return program;
|
|
|
|
|
},
|
|
|
|
|
program: function(fn, data) {
|
|
|
|
|
return function(context, options) {
|
|
|
|
|
program: function(i, fn, data) {
|
|
|
|
|
var program = function(context, options) {
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
|
return fn(context, options.data || data);
|
|
|
|
|
};
|
|
|
|
|
program.program = i;
|
|
|
|
|
program.depth = 0;
|
|
|
|
|
return program;
|
|
|
|
|
},
|
|
|
|
|
noop: function() { return ""; },
|
|
|
|
|
invokePartial: function(partial, name, context, helpers, partials, data) {
|
|
|
|
|