react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / handlebars / dist / handlebars.runtime.amd.js
80684 views/*!12handlebars v3.0.034Copyright (C) 2011-2014 by Yehuda Katz56Permission is hereby granted, free of charge, to any person obtaining a copy7of this software and associated documentation files (the "Software"), to deal8in the Software without restriction, including without limitation the rights9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell10copies of the Software, and to permit persons to whom the Software is11furnished to do so, subject to the following conditions:1213The above copyright notice and this permission notice shall be included in14all copies or substantial portions of the Software.1516THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN22THE SOFTWARE.2324@license25*/26define(27'handlebars/utils',["exports"],28function(__exports__) {2930/*jshint -W004 */31var escape = {32"&": "&",33"<": "<",34">": ">",35'"': """,36"'": "'",37"`": "`"38};3940var badChars = /[&<>"'`]/g;41var possible = /[&<>"'`]/;4243function escapeChar(chr) {44return escape[chr];45}4647function extend(obj /* , ...source */) {48for (var i = 1; i < arguments.length; i++) {49for (var key in arguments[i]) {50if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {51obj[key] = arguments[i][key];52}53}54}5556return obj;57}5859__exports__.extend = extend;var toString = Object.prototype.toString;60__exports__.toString = toString;61// Sourced from lodash62// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt63var isFunction = function(value) {64return typeof value === 'function';65};66// fallback for older versions of Chrome and Safari67/* istanbul ignore next */68if (isFunction(/x/)) {69isFunction = function(value) {70return typeof value === 'function' && toString.call(value) === '[object Function]';71};72}73var isFunction;74__exports__.isFunction = isFunction;75/* istanbul ignore next */76var isArray = Array.isArray || function(value) {77return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;78};79__exports__.isArray = isArray;80// Older IE versions do not directly support indexOf so we must implement our own, sadly.81function indexOf(array, value) {82for (var i = 0, len = array.length; i < len; i++) {83if (array[i] === value) {84return i;85}86}87return -1;88}8990__exports__.indexOf = indexOf;91function escapeExpression(string) {92// don't escape SafeStrings, since they're already safe93if (string && string.toHTML) {94return string.toHTML();95} else if (string == null) {96return "";97} else if (!string) {98return string + '';99}100101// Force a string conversion as this will be done by the append regardless and102// the regex test will do this transparently behind the scenes, causing issues if103// an object's to string has escaped characters in it.104string = "" + string;105106if(!possible.test(string)) { return string; }107return string.replace(badChars, escapeChar);108}109110__exports__.escapeExpression = escapeExpression;function isEmpty(value) {111if (!value && value !== 0) {112return true;113} else if (isArray(value) && value.length === 0) {114return true;115} else {116return false;117}118}119120__exports__.isEmpty = isEmpty;function blockParams(params, ids) {121params.path = ids;122return params;123}124125__exports__.blockParams = blockParams;function appendContextPath(contextPath, id) {126return (contextPath ? contextPath + '.' : '') + id;127}128129__exports__.appendContextPath = appendContextPath;130});131define(132'handlebars/exception',["exports"],133function(__exports__) {134135136var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];137138function Exception(message, node) {139var loc = node && node.loc,140line,141column;142if (loc) {143line = loc.start.line;144column = loc.start.column;145146message += ' - ' + line + ':' + column;147}148149var tmp = Error.prototype.constructor.call(this, message);150151// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.152for (var idx = 0; idx < errorProps.length; idx++) {153this[errorProps[idx]] = tmp[errorProps[idx]];154}155156if (loc) {157this.lineNumber = line;158this.column = column;159}160}161162Exception.prototype = new Error();163164__exports__["default"] = Exception;165});166define(167'handlebars/base',["./utils","./exception","exports"],168function(__dependency1__, __dependency2__, __exports__) {169170var Utils = __dependency1__;171var Exception = __dependency2__["default"];172173var VERSION = "3.0.0";174__exports__.VERSION = VERSION;var COMPILER_REVISION = 6;175__exports__.COMPILER_REVISION = COMPILER_REVISION;176var REVISION_CHANGES = {1771: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it1782: '== 1.0.0-rc.3',1793: '== 1.0.0-rc.4',1804: '== 1.x.x',1815: '== 2.0.0-alpha.x',1826: '>= 2.0.0-beta.1'183};184__exports__.REVISION_CHANGES = REVISION_CHANGES;185var isArray = Utils.isArray,186isFunction = Utils.isFunction,187toString = Utils.toString,188objectType = '[object Object]';189190function HandlebarsEnvironment(helpers, partials) {191this.helpers = helpers || {};192this.partials = partials || {};193194registerDefaultHelpers(this);195}196197__exports__.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = {198constructor: HandlebarsEnvironment,199200logger: logger,201log: log,202203registerHelper: function(name, fn) {204if (toString.call(name) === objectType) {205if (fn) { throw new Exception('Arg not supported with multiple helpers'); }206Utils.extend(this.helpers, name);207} else {208this.helpers[name] = fn;209}210},211unregisterHelper: function(name) {212delete this.helpers[name];213},214215registerPartial: function(name, partial) {216if (toString.call(name) === objectType) {217Utils.extend(this.partials, name);218} else {219if (typeof partial === 'undefined') {220throw new Exception('Attempting to register a partial as undefined');221}222this.partials[name] = partial;223}224},225unregisterPartial: function(name) {226delete this.partials[name];227}228};229230function registerDefaultHelpers(instance) {231instance.registerHelper('helperMissing', function(/* [args, ]options */) {232if(arguments.length === 1) {233// A missing field in a {{foo}} constuct.234return undefined;235} else {236// Someone is actually trying to call something, blow up.237throw new Exception("Missing helper: '" + arguments[arguments.length-1].name + "'");238}239});240241instance.registerHelper('blockHelperMissing', function(context, options) {242var inverse = options.inverse,243fn = options.fn;244245if(context === true) {246return fn(this);247} else if(context === false || context == null) {248return inverse(this);249} else if (isArray(context)) {250if(context.length > 0) {251if (options.ids) {252options.ids = [options.name];253}254255return instance.helpers.each(context, options);256} else {257return inverse(this);258}259} else {260if (options.data && options.ids) {261var data = createFrame(options.data);262data.contextPath = Utils.appendContextPath(options.data.contextPath, options.name);263options = {data: data};264}265266return fn(context, options);267}268});269270instance.registerHelper('each', function(context, options) {271if (!options) {272throw new Exception('Must pass iterator to #each');273}274275var fn = options.fn, inverse = options.inverse;276var i = 0, ret = "", data;277278var contextPath;279if (options.data && options.ids) {280contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.';281}282283if (isFunction(context)) { context = context.call(this); }284285if (options.data) {286data = createFrame(options.data);287}288289function execIteration(key, i, last) {290if (data) {291data.key = key;292data.index = i;293data.first = i === 0;294data.last = !!last;295296if (contextPath) {297data.contextPath = contextPath + key;298}299}300301ret = ret + fn(context[key], {302data: data,303blockParams: Utils.blockParams([context[key], key], [contextPath + key, null])304});305}306307if(context && typeof context === 'object') {308if (isArray(context)) {309for(var j = context.length; i<j; i++) {310execIteration(i, i, i === context.length-1);311}312} else {313var priorKey;314315for(var key in context) {316if(context.hasOwnProperty(key)) {317// We're running the iterations one step out of sync so we can detect318// the last iteration without have to scan the object twice and create319// an itermediate keys array.320if (priorKey) {321execIteration(priorKey, i-1);322}323priorKey = key;324i++;325}326}327if (priorKey) {328execIteration(priorKey, i-1, true);329}330}331}332333if(i === 0){334ret = inverse(this);335}336337return ret;338});339340instance.registerHelper('if', function(conditional, options) {341if (isFunction(conditional)) { conditional = conditional.call(this); }342343// Default behavior is to render the positive path if the value is truthy and not empty.344// The `includeZero` option may be set to treat the condtional as purely not empty based on the345// behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative.346if ((!options.hash.includeZero && !conditional) || Utils.isEmpty(conditional)) {347return options.inverse(this);348} else {349return options.fn(this);350}351});352353instance.registerHelper('unless', function(conditional, options) {354return instance.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn, hash: options.hash});355});356357instance.registerHelper('with', function(context, options) {358if (isFunction(context)) { context = context.call(this); }359360var fn = options.fn;361362if (!Utils.isEmpty(context)) {363if (options.data && options.ids) {364var data = createFrame(options.data);365data.contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]);366options = {data:data};367}368369return fn(context, options);370} else {371return options.inverse(this);372}373});374375instance.registerHelper('log', function(message, options) {376var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;377instance.log(level, message);378});379380instance.registerHelper('lookup', function(obj, field) {381return obj && obj[field];382});383}384385var logger = {386methodMap: { 0: 'debug', 1: 'info', 2: 'warn', 3: 'error' },387388// State enum389DEBUG: 0,390INFO: 1,391WARN: 2,392ERROR: 3,393level: 1,394395// Can be overridden in the host environment396log: function(level, message) {397if (typeof console !== 'undefined' && logger.level <= level) {398var method = logger.methodMap[level];399(console[method] || console.log).call(console, message);400}401}402};403__exports__.logger = logger;404var log = logger.log;405__exports__.log = log;406var createFrame = function(object) {407var frame = Utils.extend({}, object);408frame._parent = object;409return frame;410};411__exports__.createFrame = createFrame;412});413define(414'handlebars/safe-string',["exports"],415function(__exports__) {416417// Build out our basic SafeString type418function SafeString(string) {419this.string = string;420}421422SafeString.prototype.toString = SafeString.prototype.toHTML = function() {423return "" + this.string;424};425426__exports__["default"] = SafeString;427});428define(429'handlebars/runtime',["./utils","./exception","./base","exports"],430function(__dependency1__, __dependency2__, __dependency3__, __exports__) {431432var Utils = __dependency1__;433var Exception = __dependency2__["default"];434var COMPILER_REVISION = __dependency3__.COMPILER_REVISION;435var REVISION_CHANGES = __dependency3__.REVISION_CHANGES;436var createFrame = __dependency3__.createFrame;437438function checkRevision(compilerInfo) {439var compilerRevision = compilerInfo && compilerInfo[0] || 1,440currentRevision = COMPILER_REVISION;441442if (compilerRevision !== currentRevision) {443if (compilerRevision < currentRevision) {444var runtimeVersions = REVISION_CHANGES[currentRevision],445compilerVersions = REVISION_CHANGES[compilerRevision];446throw new Exception("Template was precompiled with an older version of Handlebars than the current runtime. "+447"Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+").");448} else {449// Use the embedded version info since the runtime doesn't know about this revision yet450throw new Exception("Template was precompiled with a newer version of Handlebars than the current runtime. "+451"Please update your runtime to a newer version ("+compilerInfo[1]+").");452}453}454}455456__exports__.checkRevision = checkRevision;// TODO: Remove this line and break up compilePartial457458function template(templateSpec, env) {459/* istanbul ignore next */460if (!env) {461throw new Exception("No environment passed to template");462}463if (!templateSpec || !templateSpec.main) {464throw new Exception('Unknown template object: ' + typeof templateSpec);465}466467// Note: Using env.VM references rather than local var references throughout this section to allow468// for external users to override these as psuedo-supported APIs.469env.VM.checkRevision(templateSpec.compiler);470471var invokePartialWrapper = function(partial, context, options) {472if (options.hash) {473context = Utils.extend({}, context, options.hash);474}475476partial = env.VM.resolvePartial.call(this, partial, context, options);477var result = env.VM.invokePartial.call(this, partial, context, options);478479if (result == null && env.compile) {480options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);481result = options.partials[options.name](context, options);482}483if (result != null) {484if (options.indent) {485var lines = result.split('\n');486for (var i = 0, l = lines.length; i < l; i++) {487if (!lines[i] && i + 1 === l) {488break;489}490491lines[i] = options.indent + lines[i];492}493result = lines.join('\n');494}495return result;496} else {497throw new Exception("The partial " + options.name + " could not be compiled when running in runtime-only mode");498}499};500501// Just add water502var container = {503strict: function(obj, name) {504if (!(name in obj)) {505throw new Exception('"' + name + '" not defined in ' + obj);506}507return obj[name];508},509lookup: function(depths, name) {510var len = depths.length;511for (var i = 0; i < len; i++) {512if (depths[i] && depths[i][name] != null) {513return depths[i][name];514}515}516},517lambda: function(current, context) {518return typeof current === 'function' ? current.call(context) : current;519},520521escapeExpression: Utils.escapeExpression,522invokePartial: invokePartialWrapper,523524fn: function(i) {525return templateSpec[i];526},527528programs: [],529program: function(i, data, declaredBlockParams, blockParams, depths) {530var programWrapper = this.programs[i],531fn = this.fn(i);532if (data || depths || blockParams || declaredBlockParams) {533programWrapper = program(this, i, fn, data, declaredBlockParams, blockParams, depths);534} else if (!programWrapper) {535programWrapper = this.programs[i] = program(this, i, fn);536}537return programWrapper;538},539540data: function(data, depth) {541while (data && depth--) {542data = data._parent;543}544return data;545},546merge: function(param, common) {547var ret = param || common;548549if (param && common && (param !== common)) {550ret = Utils.extend({}, common, param);551}552553return ret;554},555556noop: env.VM.noop,557compilerInfo: templateSpec.compiler558};559560var ret = function(context, options) {561options = options || {};562var data = options.data;563564ret._setup(options);565if (!options.partial && templateSpec.useData) {566data = initData(context, data);567}568var depths,569blockParams = templateSpec.useBlockParams ? [] : undefined;570if (templateSpec.useDepths) {571depths = options.depths ? [context].concat(options.depths) : [context];572}573574return templateSpec.main.call(container, context, container.helpers, container.partials, data, blockParams, depths);575};576ret.isTop = true;577578ret._setup = function(options) {579if (!options.partial) {580container.helpers = container.merge(options.helpers, env.helpers);581582if (templateSpec.usePartial) {583container.partials = container.merge(options.partials, env.partials);584}585} else {586container.helpers = options.helpers;587container.partials = options.partials;588}589};590591ret._child = function(i, data, blockParams, depths) {592if (templateSpec.useBlockParams && !blockParams) {593throw new Exception('must pass block params');594}595if (templateSpec.useDepths && !depths) {596throw new Exception('must pass parent depths');597}598599return program(container, i, templateSpec[i], data, 0, blockParams, depths);600};601return ret;602}603604__exports__.template = template;function program(container, i, fn, data, declaredBlockParams, blockParams, depths) {605var prog = function(context, options) {606options = options || {};607608return fn.call(container,609context,610container.helpers, container.partials,611options.data || data,612blockParams && [options.blockParams].concat(blockParams),613depths && [context].concat(depths));614};615prog.program = i;616prog.depth = depths ? depths.length : 0;617prog.blockParams = declaredBlockParams || 0;618return prog;619}620621__exports__.program = program;function resolvePartial(partial, context, options) {622if (!partial) {623partial = options.partials[options.name];624} else if (!partial.call && !options.name) {625// This is a dynamic partial that returned a string626options.name = partial;627partial = options.partials[partial];628}629return partial;630}631632__exports__.resolvePartial = resolvePartial;function invokePartial(partial, context, options) {633options.partial = true;634635if(partial === undefined) {636throw new Exception("The partial " + options.name + " could not be found");637} else if(partial instanceof Function) {638return partial(context, options);639}640}641642__exports__.invokePartial = invokePartial;function noop() { return ""; }643644__exports__.noop = noop;function initData(context, data) {645if (!data || !('root' in data)) {646data = data ? createFrame(data) : {};647data.root = context;648}649return data;650}651});652define(653'handlebars.runtime',["./handlebars/base","./handlebars/safe-string","./handlebars/exception","./handlebars/utils","./handlebars/runtime","exports"],654function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {655656/*globals Handlebars: true */657var base = __dependency1__;658659// Each of these augment the Handlebars object. No need to setup here.660// (This is done to easily share code between commonjs and browse envs)661var SafeString = __dependency2__["default"];662var Exception = __dependency3__["default"];663var Utils = __dependency4__;664var runtime = __dependency5__;665666// For compatibility and usage outside of module systems, make the Handlebars object a namespace667var create = function() {668var hb = new base.HandlebarsEnvironment();669670Utils.extend(hb, base);671hb.SafeString = SafeString;672hb.Exception = Exception;673hb.Utils = Utils;674hb.escapeExpression = Utils.escapeExpression;675676hb.VM = runtime;677hb.template = function(spec) {678return runtime.template(spec, hb);679};680681return hb;682};683684var Handlebars = create();685Handlebars.create = create;686687/*jshint -W040 */688/* istanbul ignore next */689var root = typeof global !== 'undefined' ? global : window,690$Handlebars = root.Handlebars;691/* istanbul ignore next */692Handlebars.noConflict = function() {693if (root.Handlebars === Handlebars) {694root.Handlebars = $Handlebars;695}696};697698Handlebars['default'] = Handlebars;699700__exports__["default"] = Handlebars;701});702703704