summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2011-07-30 11:10:13 -0500
committerkpdecker <kpdecker@gmail.com>2011-07-30 11:10:13 -0500
commit74bd8cac602dff27123eb94ea7e9522deb498c70 (patch)
tree599bc2f5276f147fd73ce638c7f26f0973d58bc4 /lib/handlebars/compiler/compiler.js
parent542d64f0be56e915c4a76b56471c7cf5f94f2bf0 (diff)
downloadhandlebars.js-74bd8cac602dff27123eb94ea7e9522deb498c70.zip
handlebars.js-74bd8cac602dff27123eb94ea7e9522deb498c70.tar.gz
handlebars.js-74bd8cac602dff27123eb94ea7e9522deb498c70.tar.bz2
Phase 1 of precompiled extraction:
Separate template logic from container construction.
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r--lib/handlebars/compiler/compiler.js35
1 files changed, 5 insertions, 30 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index fbac73b..75f852d 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -345,7 +345,7 @@ Handlebars.JavaScriptCompiler = function() {};
}
}
- return this.createFunction();
+ return this.createFunctionContext();
},
nextOpcode: function(n) {
@@ -388,25 +388,7 @@ Handlebars.JavaScriptCompiler = function() {};
this.source = out;
},
- createFunction: function() {
- var container = {
- escapeExpression: Handlebars.Utils.escapeExpression,
- invokePartial: Handlebars.VM.invokePartial,
- programs: [],
- program: function(i, helpers, partials, data) {
- var programWrapper = this.programs[i];
- if(data) {
- return Handlebars.VM.program(this.children[i], helpers, partials, data);
- } else if(programWrapper) {
- return programWrapper;
- } else {
- programWrapper = this.programs[i] = Handlebars.VM.program(this.children[i], helpers, partials);
- return programWrapper;
- }
- },
- programWithDepth: Handlebars.VM.programWithDepth,
- noop: Handlebars.VM.noop
- };
+ createFunctionContext: function() {
var locals = this.stackVars.concat(this.registers.list);
if(locals.length > 0) {
@@ -434,16 +416,9 @@ Handlebars.JavaScriptCompiler = function() {};
Handlebars.log(Handlebars.logger.DEBUG, fn.toString() + "\n\n");
- container.render = fn;
-
- container.children = this.environment.children;
-
- return function(context, options, $depth) {
- options = options || {};
- var args = [Handlebars, context, options.helpers, options.partials, options.data];
- var depth = Array.prototype.slice.call(arguments, 2);
- args = args.concat(depth);
- return container.render.apply(container, args);
+ return {
+ fn: fn,
+ children: this.environment.children
};
},