vendor/assets/javascripts/handlebars.runtime.js in handlebars_assets-0.23.4 vs vendor/assets/javascripts/handlebars.runtime.js in handlebars_assets-0.23.5
- old
+ new
@@ -1,9 +1,9 @@
/**!
@license
- handlebars v4.1.2
+ handlebars v4.3.1
Copyright (C) 2011-2017 by Yehuda Katz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -205,23 +205,26 @@
var _logger = __webpack_require__(19);
var _logger2 = _interopRequireDefault(_logger);
- var VERSION = '4.1.2';
+ var VERSION = '4.3.1';
exports.VERSION = VERSION;
- var COMPILER_REVISION = 7;
-
+ var COMPILER_REVISION = 8;
exports.COMPILER_REVISION = COMPILER_REVISION;
+ var LAST_COMPATIBLE_COMPILER_REVISION = 7;
+
+ exports.LAST_COMPATIBLE_COMPILER_REVISION = LAST_COMPATIBLE_COMPILER_REVISION;
var 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',
4: '== 1.x.x',
5: '== 2.0.0-alpha.x',
6: '>= 2.0.0-beta.1',
- 7: '>= 4.0.0'
+ 7: '>= 4.0.0 <4.3.0',
+ 8: '>= 4.3.0'
};
exports.REVISION_CHANGES = REVISION_CHANGES;
var objectType = '[object Object]';
@@ -301,10 +304,11 @@
exports.escapeExpression = escapeExpression;
exports.isEmpty = isEmpty;
exports.createFrame = createFrame;
exports.blockParams = blockParams;
exports.appendContextPath = appendContextPath;
+
var escape = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
@@ -518,10 +522,11 @@
var _interopRequireDefault = __webpack_require__(2)['default'];
exports.__esModule = true;
exports.registerDefaultHelpers = registerDefaultHelpers;
+ exports.moveHelperToHooks = moveHelperToHooks;
var _helpersBlockHelperMissing = __webpack_require__(10);
var _helpersBlockHelperMissing2 = _interopRequireDefault(_helpersBlockHelperMissing);
@@ -557,10 +562,19 @@
_helpersLog2['default'](instance);
_helpersLookup2['default'](instance);
_helpersWith2['default'](instance);
}
+ function moveHelperToHooks(instance, helperName, keepHelper) {
+ if (instance.helpers[helperName]) {
+ instance.hooks[helperName] = instance.helpers[helperName];
+ if (!keepHelper) {
+ delete instance.helpers[helperName];
+ }
+ }
+ }
+
/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
@@ -999,27 +1013,32 @@
var _exception2 = _interopRequireDefault(_exception);
var _base = __webpack_require__(3);
+ var _helpers = __webpack_require__(9);
+
function checkRevision(compilerInfo) {
var compilerRevision = compilerInfo && compilerInfo[0] || 1,
currentRevision = _base.COMPILER_REVISION;
- if (compilerRevision !== currentRevision) {
- if (compilerRevision < currentRevision) {
- var runtimeVersions = _base.REVISION_CHANGES[currentRevision],
- compilerVersions = _base.REVISION_CHANGES[compilerRevision];
- throw new _exception2['default']('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 _exception2['default']('Template was precompiled with a newer version of Handlebars than the current runtime. ' + 'Please update your runtime to a newer version (' + compilerInfo[1] + ').');
- }
+ if (compilerRevision >= _base.LAST_COMPATIBLE_COMPILER_REVISION && compilerRevision <= _base.COMPILER_REVISION) {
+ return;
}
+
+ if (compilerRevision < _base.LAST_COMPATIBLE_COMPILER_REVISION) {
+ var runtimeVersions = _base.REVISION_CHANGES[currentRevision],
+ compilerVersions = _base.REVISION_CHANGES[compilerRevision];
+ throw new _exception2['default']('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 _exception2['default']('Template was precompiled with a newer version of Handlebars than the current runtime. ' + 'Please update your runtime to a newer version (' + compilerInfo[1] + ').');
+ }
}
function template(templateSpec, env) {
+
/* istanbul ignore next */
if (!env) {
throw new _exception2['default']('No environment passed to template');
}
if (!templateSpec || !templateSpec.main) {
@@ -1027,27 +1046,32 @@
}
templateSpec.main.decorator = templateSpec.main_d;
// 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 pseudo-supported APIs.
env.VM.checkRevision(templateSpec.compiler);
+ // backwards compatibility for precompiled templates with compiler-version 7 (<4.3.0)
+ var templateWasPrecompiledWithCompilerV7 = templateSpec.compiler && templateSpec.compiler[0] === 7;
+
function invokePartialWrapper(partial, context, options) {
if (options.hash) {
context = Utils.extend({}, context, options.hash);
if (options.ids) {
options.ids[0] = true;
}
}
-
partial = env.VM.resolvePartial.call(this, partial, context, options);
- var result = env.VM.invokePartial.call(this, partial, context, options);
+ var optionsWithHooks = Utils.extend({}, options, { hooks: this.hooks });
+
+ var result = env.VM.invokePartial.call(this, partial, context, optionsWithHooks);
+
if (result == null && env.compile) {
options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);
- result = options.partials[options.name](context, options);
+ result = options.partials[options.name](context, optionsWithHooks);
}
if (result != null) {
if (options.indent) {
var lines = result.split('\n');
for (var i = 0, l = lines.length; i < l; i++) {
@@ -1110,19 +1134,10 @@
while (value && depth--) {
value = value._parent;
}
return value;
},
- merge: function merge(param, common) {
- var obj = param || common;
-
- if (param && common && param !== common) {
- obj = Utils.extend({}, common, param);
- }
-
- return obj;
- },
// An empty object to use as replacement for null-contexts
nullContext: _Object$seal({}),
noop: env.VM.noop,
compilerInfo: templateSpec.compiler
@@ -1155,22 +1170,29 @@
}
ret.isTop = true;
ret._setup = function (options) {
if (!options.partial) {
- container.helpers = container.merge(options.helpers, env.helpers);
+ container.helpers = Utils.extend({}, env.helpers, options.helpers);
if (templateSpec.usePartial) {
- container.partials = container.merge(options.partials, env.partials);
+ container.partials = Utils.extend({}, env.partials, options.partials);
}
if (templateSpec.usePartial || templateSpec.useDecorators) {
- container.decorators = container.merge(options.decorators, env.decorators);
+ container.decorators = Utils.extend({}, env.decorators, options.decorators);
}
+
+ container.hooks = {};
+
+ var keepHelperInHelpers = options.allowCallsToHelperMissing || templateWasPrecompiledWithCompilerV7;
+ _helpers.moveHelperToHooks(container, 'helperMissing', keepHelperInHelpers);
+ _helpers.moveHelperToHooks(container, 'blockHelperMissing', keepHelperInHelpers);
} else {
container.helpers = options.helpers;
container.partials = options.partials;
container.decorators = options.decorators;
+ container.hooks = options.hooks;
}
};
ret._child = function (i, data, blockParams, depths) {
if (templateSpec.useBlockParams && !blockParams) {
@@ -1202,9 +1224,13 @@
prog.program = i;
prog.depth = depths ? depths.length : 0;
prog.blockParams = declaredBlockParams || 0;
return prog;
}
+
+ /**
+ * This is currently part of the official API, therefore implementation details should not be changed.
+ */
function resolvePartial(partial, context, options) {
if (!partial) {
if (options.name === '@partial-block') {
partial = options.data['partial-block'];