diff options
author | kpdecker <kpdecker@gmail.com> | 2013-01-21 01:03:42 -0600 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2013-01-21 01:03:42 -0600 |
commit | b0c9f3d83bca630e177ea1b1e3760d4193c27dd7 (patch) | |
tree | f0d73d3ede763c0ab541b784964acf48a5d36390 /lib/handlebars/compiler/compiler.js | |
parent | b66197796615f49f3009800b401df2597f118e58 (diff) | |
download | handlebars.js-b0c9f3d83bca630e177ea1b1e3760d4193c27dd7.zip handlebars.js-b0c9f3d83bca630e177ea1b1e3760d4193c27dd7.tar.gz handlebars.js-b0c9f3d83bca630e177ea1b1e3760d4193c27dd7.tar.bz2 |
mergeSource helper
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index 7541051..0d21739 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -536,6 +536,19 @@ Handlebars.JavaScriptCompiler = function() {}; } // Perform a second pass over the output to merge content when possible + var source = this.mergeSource(); + + if (asObject) { + params.push(source); + + return Function.apply(this, params); + } else { + var functionSource = 'function ' + (this.name || '') + '(' + params.join(',') + ') {\n ' + source + '}'; + Handlebars.log(Handlebars.logger.DEBUG, functionSource + "\n\n"); + return functionSource; + } + }, + mergeSource: function() { // WARN: We are not handling the case where buffer is still populated as the source should // not have buffer append operations as their final action. var source = '', @@ -556,16 +569,7 @@ Handlebars.JavaScriptCompiler = function() {}; source += line + '\n '; } } - - if (asObject) { - params.push(source); - - return Function.apply(this, params); - } else { - var functionSource = 'function ' + (this.name || '') + '(' + params.join(',') + ') {\n ' + source + '}'; - Handlebars.log(Handlebars.logger.DEBUG, functionSource + "\n\n"); - return functionSource; - } + return source; }, // [blockValue] |