Skip to content

Commit

Permalink
In BundleTransformer.Handlebars added support of the Handlebars versi…
Browse files Browse the repository at this point in the history
…on 4.4.2
  • Loading branch information
Taritsyn committed Oct 8, 2019
1 parent 8b3925a commit 112cdb6
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@
"decorators": {
"inline": function(){}
},
"__esModule": {},
"HandlebarsEnvironment": function(){},
"VERSION": {},
"COMPILER_REVISION": {},
"LAST_COMPATIBLE_COMPILER_REVISION": {},
"REVISION_CHANGES": {
"1": {},
"2": {},
"3": {},
"4": {},
"5": {},
"6": {},
"7": {}
"7": {},
"8": {}
},
"log": function(){},
"createFrame": function(){},
Expand All @@ -41,6 +44,7 @@
"SafeString": function(){},
"Exception": function(){},
"Utils": {
"__esModule": {},
"extend": function(){},
"indexOf": function(){},
"escapeExpression": function(){},
Expand All @@ -53,6 +57,7 @@
},
"escapeExpression": function(){},
"VM": {
"__esModule": {},
"checkRevision": function(){},
"template": function(){},
"wrapProgram": function(){},
Expand All @@ -70,9 +75,4 @@
"unregisterPartial": function(){},
"registerDecorator": function(){},
"unregisterDecorator": function(){}
};

var container = {
program: function() {},
noop: function() {}
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**!
@license
handlebars v4.2.0
handlebars v4.4.2
Copyright (C) 2011-2017 by Yehuda Katz
Expand Down Expand Up @@ -207,19 +207,22 @@ return /******/ (function(modules) { // webpackBootstrap

var _logger2 = _interopRequireDefault(_logger);

var VERSION = '4.2.0';
var VERSION = '4.4.2';
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;
Expand Down Expand Up @@ -303,6 +306,7 @@ return /******/ (function(modules) { // webpackBootstrap
exports.createFrame = createFrame;
exports.blockParams = blockParams;
exports.appendContextPath = appendContextPath;

var escape = {
'&': '&amp;',
'<': '&lt;',
Expand Down Expand Up @@ -520,6 +524,7 @@ return /******/ (function(modules) { // webpackBootstrap

exports.__esModule = true;
exports.registerDefaultHelpers = registerDefaultHelpers;
exports.moveHelperToHooks = moveHelperToHooks;

var _helpersBlockHelperMissing = __webpack_require__(10);

Expand Down Expand Up @@ -559,6 +564,15 @@ return /******/ (function(modules) { // webpackBootstrap
_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__) {
Expand Down Expand Up @@ -606,7 +620,7 @@ return /******/ (function(modules) { // webpackBootstrap
/* 11 */
/***/ (function(module, exports, __webpack_require__) {

'use strict';
/* WEBPACK VAR INJECTION */(function(global) {'use strict';

var _interopRequireDefault = __webpack_require__(2)['default'];

Expand Down Expand Up @@ -668,6 +682,16 @@ return /******/ (function(modules) { // webpackBootstrap
execIteration(i, i, i === context.length - 1);
}
}
} else if (global.Symbol && context[global.Symbol.iterator]) {
var newContext = [];
var iterator = context[global.Symbol.iterator]();
for (var it = iterator.next(); !it.done; it = iterator.next()) {
newContext.push(it.value);
}
context = newContext;
for (var j = context.length; i < j; i++) {
execIteration(i, i, i === context.length - 1);
}
} else {
var priorKey = undefined;

Expand Down Expand Up @@ -698,6 +722,7 @@ return /******/ (function(modules) { // webpackBootstrap
};

module.exports = exports['default'];
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))

/***/ }),
/* 12 */
Expand Down Expand Up @@ -1001,23 +1026,28 @@ return /******/ (function(modules) { // webpackBootstrap

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');
Expand All @@ -1029,23 +1059,28 @@ return /******/ (function(modules) { // webpackBootstrap
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) {
Expand Down Expand Up @@ -1112,15 +1147,6 @@ return /******/ (function(modules) { // webpackBootstrap
}
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({}),

Expand Down Expand Up @@ -1157,18 +1183,25 @@ return /******/ (function(modules) { // webpackBootstrap

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;
}
};

Expand Down
Loading

0 comments on commit 112cdb6

Please sign in to comment.