Defer content output

Allows for stripping of the content after the fact.
This commit is contained in:
kpdecker
2013-07-30 11:06:54 -05:00
parent 1de6cee1b2
commit 6b0b3fa2ca
+19 -2
View File
@@ -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) {