mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Don't leave extra whitespace around slots
This commit is contained in:
parent
e27e680367
commit
7f65aade1d
@ -82,7 +82,19 @@ class Slot {
|
||||
let beforeCode = oldCode.substring(0, this._start);
|
||||
let afterCode = oldCode.substring(this._end);
|
||||
|
||||
codegen._code = beforeCode + (slotCode || '') + afterCode;
|
||||
if (slotCode) {
|
||||
codegen._code = beforeCode + slotCode + afterCode;
|
||||
} else {
|
||||
let beforeWhitespaceMatches = beforeCode.match(/[\n]\s*$/);
|
||||
if (beforeWhitespaceMatches != null) {
|
||||
let beforeWhitespace = beforeWhitespaceMatches[0];
|
||||
|
||||
if (afterCode.startsWith(beforeWhitespace)) {
|
||||
afterCode = afterCode.substring(beforeWhitespace.length);
|
||||
}
|
||||
}
|
||||
codegen._code = beforeCode + afterCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user