|
|
@ -1,8 +1,8 @@
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
|
|
|
|
|
|
|
|
handlebars v1.3.0
|
|
|
|
handlebars v2.0.0
|
|
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2011 by Yehuda Katz
|
|
|
|
Copyright (C) 2011-2014 by Yehuda Katz
|
|
|
|
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
@ -25,7 +25,15 @@
|
|
|
|
@license
|
|
|
|
@license
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
/* exported Handlebars */
|
|
|
|
/* exported Handlebars */
|
|
|
|
var Handlebars = (function() {
|
|
|
|
(function (root, factory) {
|
|
|
|
|
|
|
|
if (typeof define === 'function' && define.amd) {
|
|
|
|
|
|
|
|
define([], factory);
|
|
|
|
|
|
|
|
} else if (typeof exports === 'object') {
|
|
|
|
|
|
|
|
module.exports = factory();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
root.Handlebars = root.Handlebars || factory();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}(this, function () {
|
|
|
|
// handlebars/safe-string.js
|
|
|
|
// handlebars/safe-string.js
|
|
|
|
var __module3__ = (function() {
|
|
|
|
var __module3__ = (function() {
|
|
|
|
"use strict";
|
|
|
|
"use strict";
|
|
|
@ -63,15 +71,19 @@ var Handlebars = (function() {
|
|
|
|
var possible = /[&<>"'`]/;
|
|
|
|
var possible = /[&<>"'`]/;
|
|
|
|
|
|
|
|
|
|
|
|
function escapeChar(chr) {
|
|
|
|
function escapeChar(chr) {
|
|
|
|
return escape[chr] || "&";
|
|
|
|
return escape[chr];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function extend(obj, value) {
|
|
|
|
function extend(obj /* , ...source */) {
|
|
|
|
for(var key in value) {
|
|
|
|
for (var i = 1; i < arguments.length; i++) {
|
|
|
|
if(Object.prototype.hasOwnProperty.call(value, key)) {
|
|
|
|
for (var key in arguments[i]) {
|
|
|
|
obj[key] = value[key];
|
|
|
|
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
|
|
|
|
|
|
|
|
obj[key] = arguments[i][key];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.extend = extend;var toString = Object.prototype.toString;
|
|
|
|
__exports__.extend = extend;var toString = Object.prototype.toString;
|
|
|
@ -82,6 +94,7 @@ var Handlebars = (function() {
|
|
|
|
return typeof value === 'function';
|
|
|
|
return typeof value === 'function';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// fallback for older versions of Chrome and Safari
|
|
|
|
// fallback for older versions of Chrome and Safari
|
|
|
|
|
|
|
|
/* istanbul ignore next */
|
|
|
|
if (isFunction(/x/)) {
|
|
|
|
if (isFunction(/x/)) {
|
|
|
|
isFunction = function(value) {
|
|
|
|
isFunction = function(value) {
|
|
|
|
return typeof value === 'function' && toString.call(value) === '[object Function]';
|
|
|
|
return typeof value === 'function' && toString.call(value) === '[object Function]';
|
|
|
@ -89,6 +102,7 @@ var Handlebars = (function() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var isFunction;
|
|
|
|
var isFunction;
|
|
|
|
__exports__.isFunction = isFunction;
|
|
|
|
__exports__.isFunction = isFunction;
|
|
|
|
|
|
|
|
/* istanbul ignore next */
|
|
|
|
var isArray = Array.isArray || function(value) {
|
|
|
|
var isArray = Array.isArray || function(value) {
|
|
|
|
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
|
|
|
|
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -98,8 +112,10 @@ var Handlebars = (function() {
|
|
|
|
// don't escape SafeStrings, since they're already safe
|
|
|
|
// don't escape SafeStrings, since they're already safe
|
|
|
|
if (string instanceof SafeString) {
|
|
|
|
if (string instanceof SafeString) {
|
|
|
|
return string.toString();
|
|
|
|
return string.toString();
|
|
|
|
} else if (!string && string !== 0) {
|
|
|
|
} else if (string == null) {
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
|
|
|
|
} else if (!string) {
|
|
|
|
|
|
|
|
return string + '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Force a string conversion as this will be done by the append regardless and
|
|
|
|
// Force a string conversion as this will be done by the append regardless and
|
|
|
@ -121,7 +137,11 @@ var Handlebars = (function() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.isEmpty = isEmpty;
|
|
|
|
__exports__.isEmpty = isEmpty;function appendContextPath(contextPath, id) {
|
|
|
|
|
|
|
|
return (contextPath ? contextPath + '.' : '') + id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.appendContextPath = appendContextPath;
|
|
|
|
return __exports__;
|
|
|
|
return __exports__;
|
|
|
|
})(__module3__);
|
|
|
|
})(__module3__);
|
|
|
|
|
|
|
|
|
|
|
@ -166,14 +186,16 @@ var Handlebars = (function() {
|
|
|
|
var Utils = __dependency1__;
|
|
|
|
var Utils = __dependency1__;
|
|
|
|
var Exception = __dependency2__;
|
|
|
|
var Exception = __dependency2__;
|
|
|
|
|
|
|
|
|
|
|
|
var VERSION = "1.3.0";
|
|
|
|
var VERSION = "2.0.0";
|
|
|
|
__exports__.VERSION = VERSION;var COMPILER_REVISION = 4;
|
|
|
|
__exports__.VERSION = VERSION;var COMPILER_REVISION = 6;
|
|
|
|
__exports__.COMPILER_REVISION = COMPILER_REVISION;
|
|
|
|
__exports__.COMPILER_REVISION = COMPILER_REVISION;
|
|
|
|
var REVISION_CHANGES = {
|
|
|
|
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.x.x',
|
|
|
|
|
|
|
|
5: '== 2.0.0-alpha.x',
|
|
|
|
|
|
|
|
6: '>= 2.0.0-beta.1'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
__exports__.REVISION_CHANGES = REVISION_CHANGES;
|
|
|
|
__exports__.REVISION_CHANGES = REVISION_CHANGES;
|
|
|
|
var isArray = Utils.isArray,
|
|
|
|
var isArray = Utils.isArray,
|
|
|
@ -194,38 +216,44 @@ var Handlebars = (function() {
|
|
|
|
logger: logger,
|
|
|
|
logger: logger,
|
|
|
|
log: log,
|
|
|
|
log: log,
|
|
|
|
|
|
|
|
|
|
|
|
registerHelper: function(name, fn, inverse) {
|
|
|
|
registerHelper: function(name, fn) {
|
|
|
|
if (toString.call(name) === objectType) {
|
|
|
|
if (toString.call(name) === objectType) {
|
|
|
|
if (inverse || fn) { throw new Exception('Arg not supported with multiple helpers'); }
|
|
|
|
if (fn) { throw new Exception('Arg not supported with multiple helpers'); }
|
|
|
|
Utils.extend(this.helpers, name);
|
|
|
|
Utils.extend(this.helpers, name);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (inverse) { fn.not = inverse; }
|
|
|
|
|
|
|
|
this.helpers[name] = fn;
|
|
|
|
this.helpers[name] = fn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
unregisterHelper: function(name) {
|
|
|
|
|
|
|
|
delete this.helpers[name];
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
registerPartial: function(name, str) {
|
|
|
|
registerPartial: function(name, partial) {
|
|
|
|
if (toString.call(name) === objectType) {
|
|
|
|
if (toString.call(name) === objectType) {
|
|
|
|
Utils.extend(this.partials, name);
|
|
|
|
Utils.extend(this.partials, name);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.partials[name] = str;
|
|
|
|
this.partials[name] = partial;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
unregisterPartial: function(name) {
|
|
|
|
|
|
|
|
delete this.partials[name];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function registerDefaultHelpers(instance) {
|
|
|
|
function registerDefaultHelpers(instance) {
|
|
|
|
instance.registerHelper('helperMissing', function(arg) {
|
|
|
|
instance.registerHelper('helperMissing', function(/* [args, ]options */) {
|
|
|
|
if(arguments.length === 2) {
|
|
|
|
if(arguments.length === 1) {
|
|
|
|
|
|
|
|
// A missing field in a {{foo}} constuct.
|
|
|
|
return undefined;
|
|
|
|
return undefined;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new Exception("Missing helper: '" + arg + "'");
|
|
|
|
// Someone is actually trying to call something, blow up.
|
|
|
|
|
|
|
|
throw new Exception("Missing helper: '" + arguments[arguments.length-1].name + "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
instance.registerHelper('blockHelperMissing', function(context, options) {
|
|
|
|
instance.registerHelper('blockHelperMissing', function(context, options) {
|
|
|
|
var inverse = options.inverse || function() {}, fn = options.fn;
|
|
|
|
var inverse = options.inverse,
|
|
|
|
|
|
|
|
fn = options.fn;
|
|
|
|
if (isFunction(context)) { context = context.call(this); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(context === true) {
|
|
|
|
if(context === true) {
|
|
|
|
return fn(this);
|
|
|
|
return fn(this);
|
|
|
@ -233,19 +261,38 @@ var Handlebars = (function() {
|
|
|
|
return inverse(this);
|
|
|
|
return inverse(this);
|
|
|
|
} else if (isArray(context)) {
|
|
|
|
} else if (isArray(context)) {
|
|
|
|
if(context.length > 0) {
|
|
|
|
if(context.length > 0) {
|
|
|
|
|
|
|
|
if (options.ids) {
|
|
|
|
|
|
|
|
options.ids = [options.name];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return instance.helpers.each(context, options);
|
|
|
|
return instance.helpers.each(context, options);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return inverse(this);
|
|
|
|
return inverse(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return fn(context);
|
|
|
|
if (options.data && options.ids) {
|
|
|
|
|
|
|
|
var data = createFrame(options.data);
|
|
|
|
|
|
|
|
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.name);
|
|
|
|
|
|
|
|
options = {data: data};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return fn(context, options);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
instance.registerHelper('each', function(context, options) {
|
|
|
|
instance.registerHelper('each', function(context, options) {
|
|
|
|
|
|
|
|
if (!options) {
|
|
|
|
|
|
|
|
throw new Exception('Must pass iterator to #each');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 contextPath;
|
|
|
|
|
|
|
|
if (options.data && options.ids) {
|
|
|
|
|
|
|
|
contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isFunction(context)) { context = context.call(this); }
|
|
|
|
if (isFunction(context)) { context = context.call(this); }
|
|
|
|
|
|
|
|
|
|
|
|
if (options.data) {
|
|
|
|
if (options.data) {
|
|
|
@ -259,6 +306,10 @@ var Handlebars = (function() {
|
|
|
|
data.index = i;
|
|
|
|
data.index = i;
|
|
|
|
data.first = (i === 0);
|
|
|
|
data.first = (i === 0);
|
|
|
|
data.last = (i === (context.length-1));
|
|
|
|
data.last = (i === (context.length-1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (contextPath) {
|
|
|
|
|
|
|
|
data.contextPath = contextPath + i;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = ret + fn(context[i], { data: data });
|
|
|
|
ret = ret + fn(context[i], { data: data });
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -269,6 +320,10 @@ var Handlebars = (function() {
|
|
|
|
data.key = key;
|
|
|
|
data.key = key;
|
|
|
|
data.index = i;
|
|
|
|
data.index = i;
|
|
|
|
data.first = (i === 0);
|
|
|
|
data.first = (i === 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (contextPath) {
|
|
|
|
|
|
|
|
data.contextPath = contextPath + key;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = ret + fn(context[key], {data: data});
|
|
|
|
ret = ret + fn(context[key], {data: data});
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
@ -304,12 +359,28 @@ var Handlebars = (function() {
|
|
|
|
instance.registerHelper('with', function(context, options) {
|
|
|
|
instance.registerHelper('with', function(context, options) {
|
|
|
|
if (isFunction(context)) { context = context.call(this); }
|
|
|
|
if (isFunction(context)) { context = context.call(this); }
|
|
|
|
|
|
|
|
|
|
|
|
if (!Utils.isEmpty(context)) return options.fn(context);
|
|
|
|
var fn = options.fn;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Utils.isEmpty(context)) {
|
|
|
|
|
|
|
|
if (options.data && options.ids) {
|
|
|
|
|
|
|
|
var data = createFrame(options.data);
|
|
|
|
|
|
|
|
data.contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]);
|
|
|
|
|
|
|
|
options = {data:data};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return fn(context, options);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return options.inverse(this);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
instance.registerHelper('log', function(context, options) {
|
|
|
|
instance.registerHelper('log', function(message, 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;
|
|
|
|
instance.log(level, context);
|
|
|
|
instance.log(level, message);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
instance.registerHelper('lookup', function(obj, field) {
|
|
|
|
|
|
|
|
return obj && obj[field];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -324,22 +395,22 @@ var Handlebars = (function() {
|
|
|
|
level: 3,
|
|
|
|
level: 3,
|
|
|
|
|
|
|
|
|
|
|
|
// can be overridden in the host environment
|
|
|
|
// can be overridden in the host environment
|
|
|
|
log: function(level, obj) {
|
|
|
|
log: function(level, message) {
|
|
|
|
if (logger.level <= level) {
|
|
|
|
if (logger.level <= level) {
|
|
|
|
var method = logger.methodMap[level];
|
|
|
|
var method = logger.methodMap[level];
|
|
|
|
if (typeof console !== 'undefined' && console[method]) {
|
|
|
|
if (typeof console !== 'undefined' && console[method]) {
|
|
|
|
console[method].call(console, obj);
|
|
|
|
console[method].call(console, message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
__exports__.logger = logger;
|
|
|
|
__exports__.logger = logger;
|
|
|
|
function log(level, obj) { logger.log(level, obj); }
|
|
|
|
var log = logger.log;
|
|
|
|
|
|
|
|
__exports__.log = log;
|
|
|
|
__exports__.log = log;var createFrame = function(object) {
|
|
|
|
var createFrame = function(object) {
|
|
|
|
var obj = {};
|
|
|
|
var frame = Utils.extend({}, object);
|
|
|
|
Utils.extend(obj, object);
|
|
|
|
frame._parent = object;
|
|
|
|
return obj;
|
|
|
|
return frame;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
__exports__.createFrame = createFrame;
|
|
|
|
__exports__.createFrame = createFrame;
|
|
|
|
return __exports__;
|
|
|
|
return __exports__;
|
|
|
@ -353,6 +424,7 @@ var Handlebars = (function() {
|
|
|
|
var Exception = __dependency2__;
|
|
|
|
var Exception = __dependency2__;
|
|
|
|
var COMPILER_REVISION = __dependency3__.COMPILER_REVISION;
|
|
|
|
var COMPILER_REVISION = __dependency3__.COMPILER_REVISION;
|
|
|
|
var REVISION_CHANGES = __dependency3__.REVISION_CHANGES;
|
|
|
|
var REVISION_CHANGES = __dependency3__.REVISION_CHANGES;
|
|
|
|
|
|
|
|
var createFrame = __dependency3__.createFrame;
|
|
|
|
|
|
|
|
|
|
|
|
function checkRevision(compilerInfo) {
|
|
|
|
function checkRevision(compilerInfo) {
|
|
|
|
var compilerRevision = compilerInfo && compilerInfo[0] || 1,
|
|
|
|
var compilerRevision = compilerInfo && compilerInfo[0] || 1,
|
|
|
@ -375,20 +447,43 @@ var Handlebars = (function() {
|
|
|
|
__exports__.checkRevision = checkRevision;// TODO: Remove this line and break up compilePartial
|
|
|
|
__exports__.checkRevision = checkRevision;// TODO: Remove this line and break up compilePartial
|
|
|
|
|
|
|
|
|
|
|
|
function template(templateSpec, env) {
|
|
|
|
function template(templateSpec, env) {
|
|
|
|
|
|
|
|
/* istanbul ignore next */
|
|
|
|
if (!env) {
|
|
|
|
if (!env) {
|
|
|
|
throw new Exception("No environment passed to template");
|
|
|
|
throw new Exception("No environment passed to template");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!templateSpec || !templateSpec.main) {
|
|
|
|
|
|
|
|
throw new Exception('Unknown template object: ' + typeof templateSpec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Note: Using env.VM references rather than local var references throughout this section to allow
|
|
|
|
// Note: Using env.VM references rather than local var references throughout this section to allow
|
|
|
|
// for external users to override these as psuedo-supported APIs.
|
|
|
|
// for external users to override these as psuedo-supported APIs.
|
|
|
|
var invokePartialWrapper = function(partial, name, context, helpers, partials, data) {
|
|
|
|
env.VM.checkRevision(templateSpec.compiler);
|
|
|
|
var result = env.VM.invokePartial.apply(this, arguments);
|
|
|
|
|
|
|
|
if (result != null) { return result; }
|
|
|
|
var invokePartialWrapper = function(partial, indent, name, context, hash, helpers, partials, data, depths) {
|
|
|
|
|
|
|
|
if (hash) {
|
|
|
|
if (env.compile) {
|
|
|
|
context = Utils.extend({}, context, hash);
|
|
|
|
var options = { helpers: helpers, partials: partials, data: data };
|
|
|
|
}
|
|
|
|
partials[name] = env.compile(partial, { data: data !== undefined }, env);
|
|
|
|
|
|
|
|
return partials[name](context, options);
|
|
|
|
var result = env.VM.invokePartial.call(this, partial, name, context, helpers, partials, data, depths);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result == null && env.compile) {
|
|
|
|
|
|
|
|
var options = { helpers: helpers, partials: partials, data: data, depths: depths };
|
|
|
|
|
|
|
|
partials[name] = env.compile(partial, { data: data !== undefined, compat: templateSpec.compat }, env);
|
|
|
|
|
|
|
|
result = partials[name](context, options);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result != null) {
|
|
|
|
|
|
|
|
if (indent) {
|
|
|
|
|
|
|
|
var lines = result.split('\n');
|
|
|
|
|
|
|
|
for (var i = 0, l = lines.length; i < l; i++) {
|
|
|
|
|
|
|
|
if (!lines[i] && i + 1 === l) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lines[i] = indent + lines[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result = lines.join('\n');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
|
|
|
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -396,84 +491,110 @@ var Handlebars = (function() {
|
|
|
|
|
|
|
|
|
|
|
|
// Just add water
|
|
|
|
// Just add water
|
|
|
|
var container = {
|
|
|
|
var container = {
|
|
|
|
|
|
|
|
lookup: function(depths, name) {
|
|
|
|
|
|
|
|
var len = depths.length;
|
|
|
|
|
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
|
|
|
|
|
if (depths[i] && depths[i][name] != null) {
|
|
|
|
|
|
|
|
return depths[i][name];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
lambda: function(current, context) {
|
|
|
|
|
|
|
|
return typeof current === 'function' ? current.call(context) : current;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
escapeExpression: Utils.escapeExpression,
|
|
|
|
escapeExpression: Utils.escapeExpression,
|
|
|
|
invokePartial: invokePartialWrapper,
|
|
|
|
invokePartial: invokePartialWrapper,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn: function(i) {
|
|
|
|
|
|
|
|
return templateSpec[i];
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
programs: [],
|
|
|
|
programs: [],
|
|
|
|
program: function(i, fn, data) {
|
|
|
|
program: function(i, data, depths) {
|
|
|
|
var programWrapper = this.programs[i];
|
|
|
|
var programWrapper = this.programs[i],
|
|
|
|
if(data) {
|
|
|
|
fn = this.fn(i);
|
|
|
|
programWrapper = program(i, fn, data);
|
|
|
|
if (data || depths) {
|
|
|
|
|
|
|
|
programWrapper = program(this, i, fn, data, depths);
|
|
|
|
} else if (!programWrapper) {
|
|
|
|
} else if (!programWrapper) {
|
|
|
|
programWrapper = this.programs[i] = program(i, fn);
|
|
|
|
programWrapper = this.programs[i] = program(this, i, fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return programWrapper;
|
|
|
|
return programWrapper;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data: function(data, depth) {
|
|
|
|
|
|
|
|
while (data && depth--) {
|
|
|
|
|
|
|
|
data = data._parent;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
},
|
|
|
|
merge: function(param, common) {
|
|
|
|
merge: function(param, common) {
|
|
|
|
var ret = param || common;
|
|
|
|
var ret = param || common;
|
|
|
|
|
|
|
|
|
|
|
|
if (param && common && (param !== common)) {
|
|
|
|
if (param && common && (param !== common)) {
|
|
|
|
ret = {};
|
|
|
|
ret = Utils.extend({}, common, param);
|
|
|
|
Utils.extend(ret, common);
|
|
|
|
|
|
|
|
Utils.extend(ret, param);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
programWithDepth: env.VM.programWithDepth,
|
|
|
|
|
|
|
|
noop: env.VM.noop,
|
|
|
|
noop: env.VM.noop,
|
|
|
|
compilerInfo: null
|
|
|
|
compilerInfo: templateSpec.compiler
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return function(context, options) {
|
|
|
|
var ret = function(context, options) {
|
|
|
|
options = options || {};
|
|
|
|
options = options || {};
|
|
|
|
var namespace = options.partial ? options : env,
|
|
|
|
var data = options.data;
|
|
|
|
helpers,
|
|
|
|
|
|
|
|
partials;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!options.partial) {
|
|
|
|
ret._setup(options);
|
|
|
|
helpers = options.helpers;
|
|
|
|
if (!options.partial && templateSpec.useData) {
|
|
|
|
partials = options.partials;
|
|
|
|
data = initData(context, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var result = templateSpec.call(
|
|
|
|
var depths;
|
|
|
|
container,
|
|
|
|
if (templateSpec.useDepths) {
|
|
|
|
namespace, context,
|
|
|
|
depths = options.depths ? [context].concat(options.depths) : [context];
|
|
|
|
helpers,
|
|
|
|
|
|
|
|
partials,
|
|
|
|
|
|
|
|
options.data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!options.partial) {
|
|
|
|
|
|
|
|
env.VM.checkRevision(container.compilerInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return templateSpec.main.call(container, context, container.helpers, container.partials, data, depths);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
ret.isTop = true;
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.template = template;function programWithDepth(i, fn, data /*, $depth */) {
|
|
|
|
ret._setup = function(options) {
|
|
|
|
var args = Array.prototype.slice.call(arguments, 3);
|
|
|
|
if (!options.partial) {
|
|
|
|
|
|
|
|
container.helpers = container.merge(options.helpers, env.helpers);
|
|
|
|
|
|
|
|
|
|
|
|
var prog = function(context, options) {
|
|
|
|
if (templateSpec.usePartial) {
|
|
|
|
options = options || {};
|
|
|
|
container.partials = container.merge(options.partials, env.partials);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
container.helpers = options.helpers;
|
|
|
|
|
|
|
|
container.partials = options.partials;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return fn.apply(this, [context, options.data || data].concat(args));
|
|
|
|
ret._child = function(i, data, depths) {
|
|
|
|
|
|
|
|
if (templateSpec.useDepths && !depths) {
|
|
|
|
|
|
|
|
throw new Exception('must pass parent depths');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return program(container, i, templateSpec[i], data, depths);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
prog.program = i;
|
|
|
|
return ret;
|
|
|
|
prog.depth = args.length;
|
|
|
|
|
|
|
|
return prog;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.programWithDepth = programWithDepth;function program(i, fn, data) {
|
|
|
|
__exports__.template = template;function program(container, i, fn, data, depths) {
|
|
|
|
var prog = function(context, options) {
|
|
|
|
var prog = function(context, options) {
|
|
|
|
options = options || {};
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
|
|
|
return fn(context, options.data || data);
|
|
|
|
return fn.call(container, context, container.helpers, container.partials, options.data || data, depths && [context].concat(depths));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
prog.program = i;
|
|
|
|
prog.program = i;
|
|
|
|
prog.depth = 0;
|
|
|
|
prog.depth = depths ? depths.length : 0;
|
|
|
|
return prog;
|
|
|
|
return prog;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.program = program;function invokePartial(partial, name, context, helpers, partials, data) {
|
|
|
|
__exports__.program = program;function invokePartial(partial, name, context, helpers, partials, data, depths) {
|
|
|
|
var options = { partial: true, helpers: helpers, partials: partials, data: data };
|
|
|
|
var options = { partial: true, helpers: helpers, partials: partials, data: data, depths: depths };
|
|
|
|
|
|
|
|
|
|
|
|
if(partial === undefined) {
|
|
|
|
if(partial === undefined) {
|
|
|
|
throw new Exception("The partial " + name + " could not be found");
|
|
|
|
throw new Exception("The partial " + name + " could not be found");
|
|
|
@ -484,7 +605,13 @@ var Handlebars = (function() {
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.invokePartial = invokePartial;function noop() { return ""; }
|
|
|
|
__exports__.invokePartial = invokePartial;function noop() { return ""; }
|
|
|
|
|
|
|
|
|
|
|
|
__exports__.noop = noop;
|
|
|
|
__exports__.noop = noop;function initData(context, data) {
|
|
|
|
|
|
|
|
if (!data || !('root' in data)) {
|
|
|
|
|
|
|
|
data = data ? createFrame(data) : {};
|
|
|
|
|
|
|
|
data.root = context;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
}
|
|
|
|
return __exports__;
|
|
|
|
return __exports__;
|
|
|
|
})(__module2__, __module4__, __module1__);
|
|
|
|
})(__module2__, __module4__, __module1__);
|
|
|
|
|
|
|
|
|
|
|
@ -510,6 +637,7 @@ var Handlebars = (function() {
|
|
|
|
hb.SafeString = SafeString;
|
|
|
|
hb.SafeString = SafeString;
|
|
|
|
hb.Exception = Exception;
|
|
|
|
hb.Exception = Exception;
|
|
|
|
hb.Utils = Utils;
|
|
|
|
hb.Utils = Utils;
|
|
|
|
|
|
|
|
hb.escapeExpression = Utils.escapeExpression;
|
|
|
|
|
|
|
|
|
|
|
|
hb.VM = runtime;
|
|
|
|
hb.VM = runtime;
|
|
|
|
hb.template = function(spec) {
|
|
|
|
hb.template = function(spec) {
|
|
|
@ -522,9 +650,11 @@ var Handlebars = (function() {
|
|
|
|
var Handlebars = create();
|
|
|
|
var Handlebars = create();
|
|
|
|
Handlebars.create = create;
|
|
|
|
Handlebars.create = create;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars['default'] = Handlebars;
|
|
|
|
|
|
|
|
|
|
|
|
__exports__ = Handlebars;
|
|
|
|
__exports__ = Handlebars;
|
|
|
|
return __exports__;
|
|
|
|
return __exports__;
|
|
|
|
})(__module1__, __module3__, __module4__, __module2__, __module5__);
|
|
|
|
})(__module1__, __module3__, __module4__, __module2__, __module5__);
|
|
|
|
|
|
|
|
|
|
|
|
return __module0__;
|
|
|
|
return __module0__;
|
|
|
|
})();
|
|
|
|
}));
|
|
|
|