diff options
author | kpdecker <kpdecker@gmail.com> | 2015-08-18 23:54:04 -0700 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2015-08-18 23:54:04 -0700 |
commit | 9a2d1d6009406915d1ca177ed5321e4727b9776f (patch) | |
tree | ef0532efe7e936342ad793e5917d563d34c036c8 /lib/handlebars/compiler/javascript-compiler.js | |
parent | 08093d72f086c93441e77c7605c07156e7555cad (diff) | |
download | handlebars.js-9a2d1d6009406915d1ca177ed5321e4727b9776f.zip handlebars.js-9a2d1d6009406915d1ca177ed5321e4727b9776f.tar.gz handlebars.js-9a2d1d6009406915d1ca177ed5321e4727b9776f.tar.bz2 |
Pass container rather than exec as context
There is no real need for us to do `.call(container` other than for backwards compatibility with legacy versions. Using the 4.x release as a chance to optimize this behavior.
Diffstat (limited to 'lib/handlebars/compiler/javascript-compiler.js')
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index bed2add..b8fc976 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -20,7 +20,7 @@ JavaScriptCompiler.prototype = { } }, depthedLookup: function(name) { - return [this.aliasable('this.lookup'), '(depths, "', name, '")']; + return [this.aliasable('container.lookup'), '(depths, "', name, '")']; }, compilerInfo: function() { @@ -189,7 +189,7 @@ JavaScriptCompiler.prototype = { } } - let params = ['depth0', 'helpers', 'partials', 'data']; + let params = ['container', 'depth0', 'helpers', 'partials', 'data']; if (this.useBlockParams || this.useDepths) { params.push('blockParams'); @@ -359,7 +359,7 @@ JavaScriptCompiler.prototype = { // Escape `value` and append it to the buffer appendEscaped: function() { this.pushSource(this.appendToBuffer( - [this.aliasable('this.escapeExpression'), '(', this.popStack(), ')'])); + [this.aliasable('container.escapeExpression'), '(', this.popStack(), ')'])); }, // [getContext] @@ -428,7 +428,7 @@ JavaScriptCompiler.prototype = { if (!depth) { this.pushStackLiteral('data'); } else { - this.pushStackLiteral('this.data(data, ' + depth + ')'); + this.pushStackLiteral('container.data(data, ' + depth + ')'); } this.resolvePath('data', parts, 0, true, strict); @@ -466,7 +466,7 @@ JavaScriptCompiler.prototype = { // If the `value` is a lambda, replace it on the stack by // the return value of the lambda resolvePossibleLambda: function() { - this.push([this.aliasable('this.lambda'), '(', this.popStack(), ', ', this.contextName(0), ')']); + this.push([this.aliasable('container.lambda'), '(', this.popStack(), ', ', this.contextName(0), ')']); }, // [pushStringParam] @@ -669,7 +669,7 @@ JavaScriptCompiler.prototype = { options = this.objectLiteral(options); params.push(options); - this.push(this.source.functionCall('this.invokePartial', '', params)); + this.push(this.source.functionCall('container.invokePartial', '', params)); }, // [assignToHash] @@ -771,7 +771,7 @@ JavaScriptCompiler.prototype = { programParams.push('depths'); } - return 'this.program(' + programParams.join(', ') + ')'; + return 'container.program(' + programParams.join(', ') + ')'; }, useRegister: function(name) { @@ -965,8 +965,8 @@ JavaScriptCompiler.prototype = { // Avoid setting fn and inverse if neither are set. This allows // helpers to do a check for `if (options.fn)` if (program || inverse) { - options.fn = program || 'this.noop'; - options.inverse = inverse || 'this.noop'; + options.fn = program || 'container.noop'; + options.inverse = inverse || 'container.noop'; } // The parameters go on to the stack in order (making sure that they are evaluated in order) @@ -1061,7 +1061,7 @@ function strictLookup(requireTerminal, compiler, parts, type) { } if (requireTerminal) { - return [compiler.aliasable('this.strict'), '(', stack, ', ', compiler.quotedString(parts[i]), ')']; + return [compiler.aliasable('container.strict'), '(', stack, ', ', compiler.quotedString(parts[i]), ')']; } else { return stack; } |