mergeSource helper

This commit is contained in:
kpdecker
2013-01-21 01:03:42 -06:00
parent b661977966
commit b0c9f3d83b
+14 -10
View File
@@ -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]