handlebars.runtime.js in handlebars-source-4.2.2 vs handlebars.runtime.js in handlebars-source-4.3.0

- old
+ new

@@ -1,9 +1,9 @@ /**! @license - handlebars v4.2.2 + handlebars v4.3.0 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,24 @@ var _logger = __webpack_require__(19); var _logger2 = _interopRequireDefault(_logger); - var VERSION = '4.2.2'; + var VERSION = '4.3.0'; exports.VERSION = VERSION; - var COMPILER_REVISION = 7; + var COMPILER_REVISION = 8; 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 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 +302,11 @@ exports.escapeExpression = escapeExpression; exports.isEmpty = isEmpty; exports.createFrame = createFrame; exports.blockParams = blockParams; exports.appendContextPath = appendContextPath; + var escape = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', @@ -518,10 +520,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 +560,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,10 +1011,12 @@ 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) { @@ -1016,10 +1030,11 @@ } } } function template(templateSpec, env) { + /* istanbul ignore next */ if (!env) { throw new _exception2['default']('No environment passed to template'); } if (!templateSpec || !templateSpec.main) { @@ -1037,17 +1052,19 @@ 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 +1127,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,21 +1163,27 @@ } 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 keepHelper = options.allowCallsToHelperMissing; + _helpers.moveHelperToHooks(container, 'helperMissing', keepHelper); + _helpers.moveHelperToHooks(container, 'blockHelperMissing', keepHelper); } 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) { \ No newline at end of file