summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
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]