mergeSource helper
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user