diff options
author | kpdecker <kpdecker@gmail.com> | 2014-11-28 23:56:41 -0600 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2014-11-29 18:02:58 -0600 |
commit | b6ba2dcdb0684bc9623e2d79e4548339640fb009 (patch) | |
tree | d8955b30e5f680c42c9c373583845f55cf6b23ee | |
parent | 5b0efc7e91e6f563301fb0b1823a0fe9cf4cc40e (diff) | |
download | handlebars.js-b6ba2dcdb0684bc9623e2d79e4548339640fb009.zip handlebars.js-b6ba2dcdb0684bc9623e2d79e4548339640fb009.tar.gz handlebars.js-b6ba2dcdb0684bc9623e2d79e4548339640fb009.tar.bz2 |
Move compileProgram out of visitor methods
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index 4b5b0af..534ddb8 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -91,6 +91,24 @@ Compiler.prototype = { return this.accept(program); }, + compileProgram: function(program) { + var result = new this.compiler().compile(program, this.options); + var guid = this.guid++, depth; + + this.usePartial = this.usePartial || result.usePartial; + + this.children[guid] = result; + + for(var i=0, l=result.depths.list.length; i<l; i++) { + depth = result.depths.list[i]; + + if(depth < 2) { continue; } + else { this.addDepth(depth - 1); } + } + + return guid; + }, + accept: function(node) { this.sourceNode.unshift(node); var ret = this[node.type](node); @@ -114,24 +132,6 @@ Compiler.prototype = { return this; }, - compileProgram: function(program) { - var result = new this.compiler().compile(program, this.options); - var guid = this.guid++, depth; - - this.usePartial = this.usePartial || result.usePartial; - - this.children[guid] = result; - - for(var i=0, l=result.depths.list.length; i<l; i++) { - depth = result.depths.list[i]; - - if(depth < 2) { continue; } - else { this.addDepth(depth - 1); } - } - - return guid; - }, - BlockStatement: function(block) { var sexpr = block.sexpr, program = block.program, |