summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2013-01-21 01:03:42 -0600
committerkpdecker <kpdecker@gmail.com>2013-01-21 01:03:42 -0600
commitb0c9f3d83bca630e177ea1b1e3760d4193c27dd7 (patch)
treef0d73d3ede763c0ab541b784964acf48a5d36390 /lib/handlebars/compiler/compiler.js
parentb66197796615f49f3009800b401df2597f118e58 (diff)
downloadhandlebars.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.js24
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]