Defer content output
Allows for stripping of the content after the fact.
This commit is contained in:
@@ -77,6 +77,9 @@ JavaScriptCompiler.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
// Flush any trailing content that might be pending.
|
||||
this.pushSource('');
|
||||
|
||||
return this.createFunctionContext(asObject);
|
||||
},
|
||||
|
||||
@@ -233,7 +236,14 @@ JavaScriptCompiler.prototype = {
|
||||
//
|
||||
// Appends the string value of `content` to the current buffer
|
||||
appendContent: function(content) {
|
||||
this.pushSource(this.appendToBuffer(this.quotedString(content)));
|
||||
if (this.pendingContent) {
|
||||
content = this.pendingContent + content;
|
||||
}
|
||||
if (this.stripNext) {
|
||||
content = content.replace(/^\s+/, '');
|
||||
}
|
||||
|
||||
this.pendingContent = content;
|
||||
},
|
||||
|
||||
// [append]
|
||||
@@ -612,7 +622,14 @@ JavaScriptCompiler.prototype = {
|
||||
},
|
||||
|
||||
pushSource: function(source) {
|
||||
this.source.push(source);
|
||||
if (this.pendingContent) {
|
||||
this.source.push(this.appendToBuffer(this.quotedString(this.pendingContent)));
|
||||
this.pendingContent = undefined;
|
||||
}
|
||||
|
||||
if (source) {
|
||||
this.source.push(source);
|
||||
}
|
||||
},
|
||||
|
||||
pushStack: function(item) {
|
||||
|
||||
Reference in New Issue
Block a user