Use terinary operator for inline appends
Allows for append operations to avoid breaking inline chain.
This commit is contained in:
@@ -289,13 +289,18 @@ JavaScriptCompiler.prototype = {
|
||||
// If `value` is truthy, or 0, it is coerced into a string and appended
|
||||
// Otherwise, the empty string is appended
|
||||
append: function() {
|
||||
// Force anything that is inlined onto the stack so we don't have duplication
|
||||
// when we examine local
|
||||
this.flushInline();
|
||||
var local = this.popStack();
|
||||
this.pushSource('if (' + local + ' != null) { ' + this.appendToBuffer(local) + ' }');
|
||||
if (this.environment.isSimple) {
|
||||
this.pushSource("else { " + this.appendToBuffer("''") + " }");
|
||||
if (this.isInline()) {
|
||||
this.replaceStack(function(current) {
|
||||
return ' != null ? ' + current + ' : ""';
|
||||
});
|
||||
|
||||
this.pushSource(this.appendToBuffer(this.popStack()));
|
||||
} else {
|
||||
var local = this.popStack();
|
||||
this.pushSource('if (' + local + ' != null) { ' + this.appendToBuffer(local) + ' }');
|
||||
if (this.environment.isSimple) {
|
||||
this.pushSource("else { " + this.appendToBuffer("''") + " }");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user