Move lambda resolution to runtime
This has a very positive impact on precompiled output size, particularly for known-helpers cases, and little or no impact on the throughput numbers.
This commit is contained in:
@@ -377,11 +377,9 @@ JavaScriptCompiler.prototype = {
|
||||
// If the `value` is a lambda, replace it on the stack by
|
||||
// the return value of the lambda
|
||||
resolvePossibleLambda: function() {
|
||||
this.aliases.functionType = '"function"';
|
||||
this.aliases.lambda = 'this.lambda';
|
||||
|
||||
this.replaceStack(function(current) {
|
||||
return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current;
|
||||
});
|
||||
this.push('lambda(' + this.popStack() + ', depth0)');
|
||||
},
|
||||
|
||||
// [lookup]
|
||||
|
||||
@@ -50,6 +50,10 @@ export function template(templateSpec, env) {
|
||||
|
||||
// Just add water
|
||||
var container = {
|
||||
lambda: function(current, context) {
|
||||
return typeof current === 'function' ? current.call(context) : current;
|
||||
},
|
||||
|
||||
escapeExpression: Utils.escapeExpression,
|
||||
invokePartial: invokePartialWrapper,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user