Create contextName helper for context lookup
This commit is contained in:
@@ -214,7 +214,8 @@ Compiler.prototype = {
|
||||
if (partial.context) {
|
||||
this.accept(partial.context);
|
||||
} else {
|
||||
this.opcode('push', 'depth0');
|
||||
this.opcode('getContext', 0);
|
||||
this.opcode('pushContext');
|
||||
}
|
||||
|
||||
this.opcode('invokePartial', partialName.name, partial.indent || '');
|
||||
|
||||
@@ -230,7 +230,7 @@ JavaScriptCompiler.prototype = {
|
||||
blockValue: function(name) {
|
||||
this.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
|
||||
|
||||
var params = ["depth0"];
|
||||
var params = [this.contextName(0)];
|
||||
this.setupParams(name, 0, params);
|
||||
|
||||
this.replaceStack(function(current) {
|
||||
@@ -249,7 +249,7 @@ JavaScriptCompiler.prototype = {
|
||||
this.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
|
||||
|
||||
// We're being a bit cheeky and reusing the options value from the prior exec
|
||||
var params = ["depth0"];
|
||||
var params = [this.contextName(0)];
|
||||
this.setupParams('', 0, params, true);
|
||||
|
||||
this.flushInline();
|
||||
@@ -341,7 +341,7 @@ JavaScriptCompiler.prototype = {
|
||||
//
|
||||
// Pushes the value of the current context onto the stack.
|
||||
pushContext: function() {
|
||||
this.pushStackLiteral('depth' + this.lastContext);
|
||||
this.pushStackLiteral(this.contextName(this.lastContext));
|
||||
},
|
||||
|
||||
// [lookupOnContext]
|
||||
@@ -410,7 +410,7 @@ JavaScriptCompiler.prototype = {
|
||||
resolvePossibleLambda: function() {
|
||||
this.aliases.lambda = 'this.lambda';
|
||||
|
||||
this.push('lambda(' + this.popStack() + ', depth0)');
|
||||
this.push('lambda(' + this.popStack() + ', ' + this.contextName(0) + ')');
|
||||
},
|
||||
|
||||
// [pushStringParam]
|
||||
@@ -422,8 +422,7 @@ JavaScriptCompiler.prototype = {
|
||||
// provides the string value of a parameter along with its
|
||||
// depth rather than resolving it immediately.
|
||||
pushStringParam: function(string, type) {
|
||||
this.pushStackLiteral('depth' + this.lastContext);
|
||||
|
||||
this.pushContext();
|
||||
this.pushString(type);
|
||||
|
||||
// If it's a subexpression, the string result
|
||||
@@ -847,6 +846,10 @@ JavaScriptCompiler.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
contextName: function(context) {
|
||||
return 'depth' + context;
|
||||
},
|
||||
|
||||
quotedString: function(str) {
|
||||
return '"' + str
|
||||
.replace(/\\/g, '\\\\')
|
||||
@@ -878,7 +881,7 @@ JavaScriptCompiler.prototype = {
|
||||
params: params,
|
||||
paramsInit: paramsInit,
|
||||
name: foundHelper,
|
||||
callParams: ["depth0"].concat(params).join(", ")
|
||||
callParams: [this.contextName(0)].concat(params).join(", ")
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user