|
|
@ -1,4 +1,6 @@
|
|
|
|
/*
|
|
|
|
/*!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handlebars v1.3.0
|
|
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2011 by Yehuda Katz
|
|
|
|
Copyright (C) 2011 by Yehuda Katz
|
|
|
|
|
|
|
|
|
|
|
@ -22,70 +24,216 @@ THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
@license
|
|
|
|
@license
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* exported Handlebars */
|
|
|
|
|
|
|
|
var Handlebars = (function() {
|
|
|
|
|
|
|
|
// handlebars/safe-string.js
|
|
|
|
|
|
|
|
var __module3__ = (function() {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var __exports__;
|
|
|
|
|
|
|
|
// Build out our basic SafeString type
|
|
|
|
|
|
|
|
function SafeString(string) {
|
|
|
|
|
|
|
|
this.string = string;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SafeString.prototype.toString = function() {
|
|
|
|
|
|
|
|
return "" + this.string;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__exports__ = SafeString;
|
|
|
|
|
|
|
|
return __exports__;
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handlebars/utils.js
|
|
|
|
|
|
|
|
var __module2__ = (function(__dependency1__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var __exports__ = {};
|
|
|
|
|
|
|
|
/*jshint -W004 */
|
|
|
|
|
|
|
|
var SafeString = __dependency1__;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var escape = {
|
|
|
|
|
|
|
|
"&": "&",
|
|
|
|
|
|
|
|
"<": "<",
|
|
|
|
|
|
|
|
">": ">",
|
|
|
|
|
|
|
|
'"': """,
|
|
|
|
|
|
|
|
"'": "'",
|
|
|
|
|
|
|
|
"`": "`"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var badChars = /[&<>"'`]/g;
|
|
|
|
|
|
|
|
var possible = /[&<>"'`]/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function escapeChar(chr) {
|
|
|
|
|
|
|
|
return escape[chr] || "&";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// lib/handlebars/browser-prefix.js
|
|
|
|
function extend(obj, value) {
|
|
|
|
(function(undefined) {
|
|
|
|
for(var key in value) {
|
|
|
|
var Handlebars = {};
|
|
|
|
if(Object.prototype.hasOwnProperty.call(value, key)) {
|
|
|
|
;
|
|
|
|
obj[key] = value[key];
|
|
|
|
// lib/handlebars/base.js
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.VERSION = "1.0.0";
|
|
|
|
__exports__.extend = extend;var toString = Object.prototype.toString;
|
|
|
|
Handlebars.COMPILER_REVISION = 4;
|
|
|
|
__exports__.toString = toString;
|
|
|
|
|
|
|
|
// Sourced from lodash
|
|
|
|
|
|
|
|
// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
|
|
|
|
|
|
|
|
var isFunction = function(value) {
|
|
|
|
|
|
|
|
return typeof value === 'function';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// fallback for older versions of Chrome and Safari
|
|
|
|
|
|
|
|
if (isFunction(/x/)) {
|
|
|
|
|
|
|
|
isFunction = function(value) {
|
|
|
|
|
|
|
|
return typeof value === 'function' && toString.call(value) === '[object Function]';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var isFunction;
|
|
|
|
|
|
|
|
__exports__.isFunction = isFunction;
|
|
|
|
|
|
|
|
var isArray = Array.isArray || function(value) {
|
|
|
|
|
|
|
|
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
__exports__.isArray = isArray;
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.REVISION_CHANGES = {
|
|
|
|
function escapeExpression(string) {
|
|
|
|
|
|
|
|
// don't escape SafeStrings, since they're already safe
|
|
|
|
|
|
|
|
if (string instanceof SafeString) {
|
|
|
|
|
|
|
|
return string.toString();
|
|
|
|
|
|
|
|
} else if (!string && string !== 0) {
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!possible.test(string)) { return string; }
|
|
|
|
|
|
|
|
return string.replace(badChars, escapeChar);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.escapeExpression = escapeExpression;function isEmpty(value) {
|
|
|
|
|
|
|
|
if (!value && value !== 0) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else if (isArray(value) && value.length === 0) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.isEmpty = isEmpty;
|
|
|
|
|
|
|
|
return __exports__;
|
|
|
|
|
|
|
|
})(__module3__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handlebars/exception.js
|
|
|
|
|
|
|
|
var __module4__ = (function() {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var __exports__;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Exception(message, node) {
|
|
|
|
|
|
|
|
var line;
|
|
|
|
|
|
|
|
if (node && node.firstLine) {
|
|
|
|
|
|
|
|
line = node.firstLine;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
message += ' - ' + line + ':' + node.firstColumn;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tmp = Error.prototype.constructor.call(this, message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
|
|
|
|
|
|
|
|
for (var idx = 0; idx < errorProps.length; idx++) {
|
|
|
|
|
|
|
|
this[errorProps[idx]] = tmp[errorProps[idx]];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (line) {
|
|
|
|
|
|
|
|
this.lineNumber = line;
|
|
|
|
|
|
|
|
this.column = node.firstColumn;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Exception.prototype = new Error();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__exports__ = Exception;
|
|
|
|
|
|
|
|
return __exports__;
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handlebars/base.js
|
|
|
|
|
|
|
|
var __module1__ = (function(__dependency1__, __dependency2__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var __exports__ = {};
|
|
|
|
|
|
|
|
var Utils = __dependency1__;
|
|
|
|
|
|
|
|
var Exception = __dependency2__;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var VERSION = "1.3.0";
|
|
|
|
|
|
|
|
__exports__.VERSION = VERSION;var COMPILER_REVISION = 4;
|
|
|
|
|
|
|
|
__exports__.COMPILER_REVISION = COMPILER_REVISION;
|
|
|
|
|
|
|
|
var REVISION_CHANGES = {
|
|
|
|
1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
|
|
|
|
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',
|
|
|
|
3: '== 1.0.0-rc.4',
|
|
|
|
4: '>= 1.0.0'
|
|
|
|
4: '>= 1.0.0'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
__exports__.REVISION_CHANGES = REVISION_CHANGES;
|
|
|
|
|
|
|
|
var isArray = Utils.isArray,
|
|
|
|
|
|
|
|
isFunction = Utils.isFunction,
|
|
|
|
|
|
|
|
toString = Utils.toString,
|
|
|
|
|
|
|
|
objectType = '[object Object]';
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.helpers = {};
|
|
|
|
function HandlebarsEnvironment(helpers, partials) {
|
|
|
|
Handlebars.partials = {};
|
|
|
|
this.helpers = helpers || {};
|
|
|
|
|
|
|
|
this.partials = partials || {};
|
|
|
|
|
|
|
|
|
|
|
|
var toString = Object.prototype.toString,
|
|
|
|
registerDefaultHelpers(this);
|
|
|
|
functionType = '[object Function]',
|
|
|
|
}
|
|
|
|
objectType = '[object Object]';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper = function(name, fn, inverse) {
|
|
|
|
__exports__.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = {
|
|
|
|
|
|
|
|
constructor: HandlebarsEnvironment,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger: logger,
|
|
|
|
|
|
|
|
log: log,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
registerHelper: function(name, fn, inverse) {
|
|
|
|
if (toString.call(name) === objectType) {
|
|
|
|
if (toString.call(name) === objectType) {
|
|
|
|
if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); }
|
|
|
|
if (inverse || fn) { throw new Exception('Arg not supported with multiple helpers'); }
|
|
|
|
Handlebars.Utils.extend(this.helpers, name);
|
|
|
|
Utils.extend(this.helpers, name);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (inverse) { fn.not = inverse; }
|
|
|
|
if (inverse) { fn.not = inverse; }
|
|
|
|
this.helpers[name] = fn;
|
|
|
|
this.helpers[name] = fn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerPartial = function(name, str) {
|
|
|
|
registerPartial: function(name, str) {
|
|
|
|
if (toString.call(name) === objectType) {
|
|
|
|
if (toString.call(name) === objectType) {
|
|
|
|
Handlebars.Utils.extend(this.partials, name);
|
|
|
|
Utils.extend(this.partials, name);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.partials[name] = str;
|
|
|
|
this.partials[name] = str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('helperMissing', function(arg) {
|
|
|
|
function registerDefaultHelpers(instance) {
|
|
|
|
|
|
|
|
instance.registerHelper('helperMissing', function(arg) {
|
|
|
|
if(arguments.length === 2) {
|
|
|
|
if(arguments.length === 2) {
|
|
|
|
return undefined;
|
|
|
|
return undefined;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new Error("Missing helper: '" + arg + "'");
|
|
|
|
throw new Exception("Missing helper: '" + arg + "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
|
|
|
|
instance.registerHelper('blockHelperMissing', function(context, options) {
|
|
|
|
var inverse = options.inverse || function() {}, fn = options.fn;
|
|
|
|
var inverse = options.inverse || function() {}, fn = options.fn;
|
|
|
|
|
|
|
|
|
|
|
|
var type = toString.call(context);
|
|
|
|
if (isFunction(context)) { context = context.call(this); }
|
|
|
|
|
|
|
|
|
|
|
|
if(type === functionType) { context = context.call(this); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(context === true) {
|
|
|
|
if(context === true) {
|
|
|
|
return fn(this);
|
|
|
|
return fn(this);
|
|
|
|
} else if(context === false || context == null) {
|
|
|
|
} else if(context === false || context == null) {
|
|
|
|
return inverse(this);
|
|
|
|
return inverse(this);
|
|
|
|
} else if(type === "[object Array]") {
|
|
|
|
} else if (isArray(context)) {
|
|
|
|
if(context.length > 0) {
|
|
|
|
if(context.length > 0) {
|
|
|
|
return Handlebars.helpers.each(context, options);
|
|
|
|
return instance.helpers.each(context, options);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return inverse(this);
|
|
|
|
return inverse(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -94,54 +242,34 @@ Handlebars.registerHelper('blockHelperMissing', function(context, options) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.K = function() {};
|
|
|
|
instance.registerHelper('each', function(context, options) {
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.createFrame = Object.create || function(object) {
|
|
|
|
|
|
|
|
Handlebars.K.prototype = object;
|
|
|
|
|
|
|
|
var obj = new Handlebars.K();
|
|
|
|
|
|
|
|
Handlebars.K.prototype = null;
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.logger = {
|
|
|
|
|
|
|
|
DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
methodMap: {0: 'debug', 1: 'info', 2: 'warn', 3: 'error'},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// can be overridden in the host environment
|
|
|
|
|
|
|
|
log: function(level, obj) {
|
|
|
|
|
|
|
|
if (Handlebars.logger.level <= level) {
|
|
|
|
|
|
|
|
var method = Handlebars.logger.methodMap[level];
|
|
|
|
|
|
|
|
if (typeof console !== 'undefined' && console[method]) {
|
|
|
|
|
|
|
|
console[method].call(console, obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.log = function(level, obj) { Handlebars.logger.log(level, obj); };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('each', function(context, options) {
|
|
|
|
|
|
|
|
var fn = options.fn, inverse = options.inverse;
|
|
|
|
var fn = options.fn, inverse = options.inverse;
|
|
|
|
var i = 0, ret = "", data;
|
|
|
|
var i = 0, ret = "", data;
|
|
|
|
|
|
|
|
|
|
|
|
var type = toString.call(context);
|
|
|
|
if (isFunction(context)) { context = context.call(this); }
|
|
|
|
if(type === functionType) { context = context.call(this); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (options.data) {
|
|
|
|
if (options.data) {
|
|
|
|
data = Handlebars.createFrame(options.data);
|
|
|
|
data = createFrame(options.data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(context && typeof context === 'object') {
|
|
|
|
if(context && typeof context === 'object') {
|
|
|
|
if(context instanceof Array){
|
|
|
|
if (isArray(context)) {
|
|
|
|
for(var j = context.length; i<j; i++) {
|
|
|
|
for(var j = context.length; i<j; i++) {
|
|
|
|
if (data) { data.index = i; }
|
|
|
|
if (data) {
|
|
|
|
|
|
|
|
data.index = i;
|
|
|
|
|
|
|
|
data.first = (i === 0);
|
|
|
|
|
|
|
|
data.last = (i === (context.length-1));
|
|
|
|
|
|
|
|
}
|
|
|
|
ret = ret + fn(context[i], { data: data });
|
|
|
|
ret = ret + fn(context[i], { data: data });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
for(var key in context) {
|
|
|
|
for(var key in context) {
|
|
|
|
if(context.hasOwnProperty(key)) {
|
|
|
|
if(context.hasOwnProperty(key)) {
|
|
|
|
if(data) { data.key = key; }
|
|
|
|
if(data) {
|
|
|
|
|
|
|
|
data.key = key;
|
|
|
|
|
|
|
|
data.index = i;
|
|
|
|
|
|
|
|
data.first = (i === 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
ret = ret + fn(context[key], {data: data});
|
|
|
|
ret = ret + fn(context[key], {data: data});
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -156,219 +284,247 @@ Handlebars.registerHelper('each', function(context, options) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('if', function(conditional, options) {
|
|
|
|
instance.registerHelper('if', function(conditional, options) {
|
|
|
|
var type = toString.call(conditional);
|
|
|
|
if (isFunction(conditional)) { conditional = conditional.call(this); }
|
|
|
|
if(type === functionType) { conditional = conditional.call(this); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!conditional || Handlebars.Utils.isEmpty(conditional)) {
|
|
|
|
// Default behavior is to render the positive path if the value is truthy and not empty.
|
|
|
|
|
|
|
|
// The `includeZero` option may be set to treat the condtional as purely not empty based on the
|
|
|
|
|
|
|
|
// behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative.
|
|
|
|
|
|
|
|
if ((!options.hash.includeZero && !conditional) || Utils.isEmpty(conditional)) {
|
|
|
|
return options.inverse(this);
|
|
|
|
return options.inverse(this);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return options.fn(this);
|
|
|
|
return options.fn(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('unless', function(conditional, options) {
|
|
|
|
instance.registerHelper('unless', function(conditional, options) {
|
|
|
|
return Handlebars.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn});
|
|
|
|
return instance.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn, hash: options.hash});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('with', function(context, options) {
|
|
|
|
instance.registerHelper('with', function(context, options) {
|
|
|
|
var type = toString.call(context);
|
|
|
|
if (isFunction(context)) { context = context.call(this); }
|
|
|
|
if(type === functionType) { context = context.call(this); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Handlebars.Utils.isEmpty(context)) return options.fn(context);
|
|
|
|
if (!Utils.isEmpty(context)) return options.fn(context);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.registerHelper('log', function(context, options) {
|
|
|
|
instance.registerHelper('log', function(context, options) {
|
|
|
|
var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
|
|
|
|
var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
|
|
|
|
Handlebars.log(level, context);
|
|
|
|
instance.log(level, context);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
;
|
|
|
|
}
|
|
|
|
// lib/handlebars/utils.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
|
|
|
|
var logger = {
|
|
|
|
|
|
|
|
methodMap: { 0: 'debug', 1: 'info', 2: 'warn', 3: 'error' },
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.Exception = function(message) {
|
|
|
|
// State enum
|
|
|
|
var tmp = Error.prototype.constructor.apply(this, arguments);
|
|
|
|
DEBUG: 0,
|
|
|
|
|
|
|
|
INFO: 1,
|
|
|
|
|
|
|
|
WARN: 2,
|
|
|
|
|
|
|
|
ERROR: 3,
|
|
|
|
|
|
|
|
level: 3,
|
|
|
|
|
|
|
|
|
|
|
|
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
|
|
|
|
// can be overridden in the host environment
|
|
|
|
for (var idx = 0; idx < errorProps.length; idx++) {
|
|
|
|
log: function(level, obj) {
|
|
|
|
this[errorProps[idx]] = tmp[errorProps[idx]];
|
|
|
|
if (logger.level <= level) {
|
|
|
|
|
|
|
|
var method = logger.methodMap[level];
|
|
|
|
|
|
|
|
if (typeof console !== 'undefined' && console[method]) {
|
|
|
|
|
|
|
|
console[method].call(console, obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Handlebars.Exception.prototype = new Error();
|
|
|
|
__exports__.logger = logger;
|
|
|
|
|
|
|
|
function log(level, obj) { logger.log(level, obj); }
|
|
|
|
// Build out our basic SafeString type
|
|
|
|
|
|
|
|
Handlebars.SafeString = function(string) {
|
|
|
|
|
|
|
|
this.string = string;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
Handlebars.SafeString.prototype.toString = function() {
|
|
|
|
|
|
|
|
return this.string.toString();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var escape = {
|
|
|
|
|
|
|
|
"&": "&",
|
|
|
|
|
|
|
|
"<": "<",
|
|
|
|
|
|
|
|
">": ">",
|
|
|
|
|
|
|
|
'"': """,
|
|
|
|
|
|
|
|
"'": "'",
|
|
|
|
|
|
|
|
"`": "`"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var badChars = /[&<>"'`]/g;
|
|
|
|
|
|
|
|
var possible = /[&<>"'`]/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var escapeChar = function(chr) {
|
|
|
|
__exports__.log = log;var createFrame = function(object) {
|
|
|
|
return escape[chr] || "&";
|
|
|
|
var obj = {};
|
|
|
|
|
|
|
|
Utils.extend(obj, object);
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
__exports__.createFrame = createFrame;
|
|
|
|
|
|
|
|
return __exports__;
|
|
|
|
|
|
|
|
})(__module2__, __module4__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handlebars/runtime.js
|
|
|
|
|
|
|
|
var __module5__ = (function(__dependency1__, __dependency2__, __dependency3__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var __exports__ = {};
|
|
|
|
|
|
|
|
var Utils = __dependency1__;
|
|
|
|
|
|
|
|
var Exception = __dependency2__;
|
|
|
|
|
|
|
|
var COMPILER_REVISION = __dependency3__.COMPILER_REVISION;
|
|
|
|
|
|
|
|
var REVISION_CHANGES = __dependency3__.REVISION_CHANGES;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function checkRevision(compilerInfo) {
|
|
|
|
|
|
|
|
var compilerRevision = compilerInfo && compilerInfo[0] || 1,
|
|
|
|
|
|
|
|
currentRevision = COMPILER_REVISION;
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.Utils = {
|
|
|
|
if (compilerRevision !== currentRevision) {
|
|
|
|
extend: function(obj, value) {
|
|
|
|
if (compilerRevision < currentRevision) {
|
|
|
|
for(var key in value) {
|
|
|
|
var runtimeVersions = REVISION_CHANGES[currentRevision],
|
|
|
|
if(value.hasOwnProperty(key)) {
|
|
|
|
compilerVersions = REVISION_CHANGES[compilerRevision];
|
|
|
|
obj[key] = value[key];
|
|
|
|
throw new Exception("Template was precompiled with an older version of Handlebars than the current runtime. "+
|
|
|
|
|
|
|
|
"Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+").");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Use the embedded version info since the runtime doesn't know about this revision yet
|
|
|
|
|
|
|
|
throw new Exception("Template was precompiled with a newer version of Handlebars than the current runtime. "+
|
|
|
|
|
|
|
|
"Please update your runtime to a newer version ("+compilerInfo[1]+").");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
escapeExpression: function(string) {
|
|
|
|
|
|
|
|
// don't escape SafeStrings, since they're already safe
|
|
|
|
|
|
|
|
if (string instanceof Handlebars.SafeString) {
|
|
|
|
|
|
|
|
return string.toString();
|
|
|
|
|
|
|
|
} else if (string == null || string === false) {
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Force a string conversion as this will be done by the append regardless and
|
|
|
|
__exports__.checkRevision = checkRevision;// TODO: Remove this line and break up compilePartial
|
|
|
|
// 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; }
|
|
|
|
function template(templateSpec, env) {
|
|
|
|
return string.replace(badChars, escapeChar);
|
|
|
|
if (!env) {
|
|
|
|
},
|
|
|
|
throw new Exception("No environment passed to template");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
isEmpty: function(value) {
|
|
|
|
// Note: Using env.VM references rather than local var references throughout this section to allow
|
|
|
|
if (!value && value !== 0) {
|
|
|
|
// for external users to override these as psuedo-supported APIs.
|
|
|
|
return true;
|
|
|
|
var invokePartialWrapper = function(partial, name, context, helpers, partials, data) {
|
|
|
|
} else if(toString.call(value) === "[object Array]" && value.length === 0) {
|
|
|
|
var result = env.VM.invokePartial.apply(this, arguments);
|
|
|
|
return true;
|
|
|
|
if (result != null) { return result; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (env.compile) {
|
|
|
|
|
|
|
|
var options = { helpers: helpers, partials: partials, data: data };
|
|
|
|
|
|
|
|
partials[name] = env.compile(partial, { data: data !== undefined }, env);
|
|
|
|
|
|
|
|
return partials[name](context, options);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
;
|
|
|
|
|
|
|
|
// lib/handlebars/runtime.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.VM = {
|
|
|
|
|
|
|
|
template: function(templateSpec) {
|
|
|
|
|
|
|
|
// Just add water
|
|
|
|
// Just add water
|
|
|
|
var container = {
|
|
|
|
var container = {
|
|
|
|
escapeExpression: Handlebars.Utils.escapeExpression,
|
|
|
|
escapeExpression: Utils.escapeExpression,
|
|
|
|
invokePartial: Handlebars.VM.invokePartial,
|
|
|
|
invokePartial: invokePartialWrapper,
|
|
|
|
programs: [],
|
|
|
|
programs: [],
|
|
|
|
program: function(i, fn, data) {
|
|
|
|
program: function(i, fn, data) {
|
|
|
|
var programWrapper = this.programs[i];
|
|
|
|
var programWrapper = this.programs[i];
|
|
|
|
if(data) {
|
|
|
|
if(data) {
|
|
|
|
programWrapper = Handlebars.VM.program(i, fn, data);
|
|
|
|
programWrapper = program(i, fn, data);
|
|
|
|
} else if (!programWrapper) {
|
|
|
|
} else if (!programWrapper) {
|
|
|
|
programWrapper = this.programs[i] = Handlebars.VM.program(i, fn);
|
|
|
|
programWrapper = this.programs[i] = program(i, fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return programWrapper;
|
|
|
|
return programWrapper;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
merge: function(param, common) {
|
|
|
|
merge: function(param, common) {
|
|
|
|
var ret = param || common;
|
|
|
|
var ret = param || common;
|
|
|
|
|
|
|
|
|
|
|
|
if (param && common) {
|
|
|
|
if (param && common && (param !== common)) {
|
|
|
|
ret = {};
|
|
|
|
ret = {};
|
|
|
|
Handlebars.Utils.extend(ret, common);
|
|
|
|
Utils.extend(ret, common);
|
|
|
|
Handlebars.Utils.extend(ret, param);
|
|
|
|
Utils.extend(ret, param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
programWithDepth: Handlebars.VM.programWithDepth,
|
|
|
|
programWithDepth: env.VM.programWithDepth,
|
|
|
|
noop: Handlebars.VM.noop,
|
|
|
|
noop: env.VM.noop,
|
|
|
|
compilerInfo: null
|
|
|
|
compilerInfo: null
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return function(context, options) {
|
|
|
|
return function(context, options) {
|
|
|
|
options = options || {};
|
|
|
|
options = options || {};
|
|
|
|
var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
|
|
|
|
var namespace = options.partial ? options : env,
|
|
|
|
|
|
|
|
helpers,
|
|
|
|
|
|
|
|
partials;
|
|
|
|
|
|
|
|
|
|
|
|
var compilerInfo = container.compilerInfo || [],
|
|
|
|
if (!options.partial) {
|
|
|
|
compilerRevision = compilerInfo[0] || 1,
|
|
|
|
helpers = options.helpers;
|
|
|
|
currentRevision = Handlebars.COMPILER_REVISION;
|
|
|
|
partials = options.partials;
|
|
|
|
|
|
|
|
|
|
|
|
if (compilerRevision !== currentRevision) {
|
|
|
|
|
|
|
|
if (compilerRevision < currentRevision) {
|
|
|
|
|
|
|
|
var runtimeVersions = Handlebars.REVISION_CHANGES[currentRevision],
|
|
|
|
|
|
|
|
compilerVersions = Handlebars.REVISION_CHANGES[compilerRevision];
|
|
|
|
|
|
|
|
throw "Template was precompiled with an older version of Handlebars than the current runtime. "+
|
|
|
|
|
|
|
|
"Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+").";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Use the embedded version info since the runtime doesn't know about this revision yet
|
|
|
|
|
|
|
|
throw "Template was precompiled with a newer version of Handlebars than the current runtime. "+
|
|
|
|
|
|
|
|
"Please update your runtime to a newer version ("+compilerInfo[1]+").";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var result = templateSpec.call(
|
|
|
|
|
|
|
|
container,
|
|
|
|
|
|
|
|
namespace, context,
|
|
|
|
|
|
|
|
helpers,
|
|
|
|
|
|
|
|
partials,
|
|
|
|
|
|
|
|
options.data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!options.partial) {
|
|
|
|
|
|
|
|
env.VM.checkRevision(container.compilerInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
programWithDepth: function(i, fn, data /*, $depth */) {
|
|
|
|
__exports__.template = template;function programWithDepth(i, fn, data /*, $depth */) {
|
|
|
|
var args = Array.prototype.slice.call(arguments, 3);
|
|
|
|
var args = Array.prototype.slice.call(arguments, 3);
|
|
|
|
|
|
|
|
|
|
|
|
var program = function(context, options) {
|
|
|
|
var prog = function(context, options) {
|
|
|
|
options = options || {};
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
|
|
|
return fn.apply(this, [context, options.data || data].concat(args));
|
|
|
|
return fn.apply(this, [context, options.data || data].concat(args));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
program.program = i;
|
|
|
|
prog.program = i;
|
|
|
|
program.depth = args.length;
|
|
|
|
prog.depth = args.length;
|
|
|
|
return program;
|
|
|
|
return prog;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
program: function(i, fn, data) {
|
|
|
|
|
|
|
|
var program = function(context, options) {
|
|
|
|
__exports__.programWithDepth = programWithDepth;function program(i, fn, data) {
|
|
|
|
|
|
|
|
var prog = function(context, options) {
|
|
|
|
options = options || {};
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
|
|
|
return fn(context, options.data || data);
|
|
|
|
return fn(context, options.data || data);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
program.program = i;
|
|
|
|
prog.program = i;
|
|
|
|
program.depth = 0;
|
|
|
|
prog.depth = 0;
|
|
|
|
return program;
|
|
|
|
return prog;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
noop: function() { return ""; },
|
|
|
|
|
|
|
|
invokePartial: function(partial, name, context, helpers, partials, data) {
|
|
|
|
__exports__.program = program;function invokePartial(partial, name, context, helpers, partials, data) {
|
|
|
|
var options = { helpers: helpers, partials: partials, data: data };
|
|
|
|
var options = { partial: true, helpers: helpers, partials: partials, data: data };
|
|
|
|
|
|
|
|
|
|
|
|
if(partial === undefined) {
|
|
|
|
if(partial === undefined) {
|
|
|
|
throw new Handlebars.Exception("The partial " + name + " could not be found");
|
|
|
|
throw new Exception("The partial " + name + " could not be found");
|
|
|
|
} else if(partial instanceof Function) {
|
|
|
|
} else if(partial instanceof Function) {
|
|
|
|
return partial(context, options);
|
|
|
|
return partial(context, options);
|
|
|
|
} else if (!Handlebars.compile) {
|
|
|
|
|
|
|
|
throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
partials[name] = Handlebars.compile(partial, {data: data !== undefined});
|
|
|
|
|
|
|
|
return partials[name](context, options);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.invokePartial = invokePartial;function noop() { return ""; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.noop = noop;
|
|
|
|
|
|
|
|
return __exports__;
|
|
|
|
|
|
|
|
})(__module2__, __module4__, __module1__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handlebars.runtime.js
|
|
|
|
|
|
|
|
var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var __exports__;
|
|
|
|
|
|
|
|
/*globals Handlebars: true */
|
|
|
|
|
|
|
|
var base = __dependency1__;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Each of these augment the Handlebars object. No need to setup here.
|
|
|
|
|
|
|
|
// (This is done to easily share code between commonjs and browse envs)
|
|
|
|
|
|
|
|
var SafeString = __dependency2__;
|
|
|
|
|
|
|
|
var Exception = __dependency3__;
|
|
|
|
|
|
|
|
var Utils = __dependency4__;
|
|
|
|
|
|
|
|
var runtime = __dependency5__;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// For compatibility and usage outside of module systems, make the Handlebars object a namespace
|
|
|
|
|
|
|
|
var create = function() {
|
|
|
|
|
|
|
|
var hb = new base.HandlebarsEnvironment();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Utils.extend(hb, base);
|
|
|
|
|
|
|
|
hb.SafeString = SafeString;
|
|
|
|
|
|
|
|
hb.Exception = Exception;
|
|
|
|
|
|
|
|
hb.Utils = Utils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hb.VM = runtime;
|
|
|
|
|
|
|
|
hb.template = function(spec) {
|
|
|
|
|
|
|
|
return runtime.template(spec, hb);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.template = Handlebars.VM.template;
|
|
|
|
return hb;
|
|
|
|
;
|
|
|
|
};
|
|
|
|
// lib/handlebars/browser-suffix.js
|
|
|
|
|
|
|
|
if (typeof module === 'object' && module.exports) {
|
|
|
|
|
|
|
|
// CommonJS
|
|
|
|
|
|
|
|
module.exports = Handlebars;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (typeof define === "function" && define.amd) {
|
|
|
|
var Handlebars = create();
|
|
|
|
// AMD modules
|
|
|
|
Handlebars.create = create;
|
|
|
|
define(function() { return Handlebars; });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
__exports__ = Handlebars;
|
|
|
|
// other, i.e. browser
|
|
|
|
return __exports__;
|
|
|
|
this.Handlebars = Handlebars;
|
|
|
|
})(__module1__, __module3__, __module4__, __module2__, __module5__);
|
|
|
|
}
|
|
|
|
|
|
|
|
}).call(this);
|
|
|
|
return __module0__;
|
|
|
|
;
|
|
|
|
})();
|
|
|
|