Skip to content

Commit b3e11a3

Browse files
committed
always remove empty lines
1 parent d76489a commit b3e11a3

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

Sources/EnumeratorMacroImpl/EnumeratorMacroType.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ extension EnumeratorMacroType: MemberMacro {
8282
guard let rendered else {
8383
return nil
8484
}
85-
return (rendered, syntax)
85+
let noEmptyLines = rendered.split(separator: "\n").joined(separator: "\n")
86+
return (noEmptyLines, syntax)
8687
} catch {
8788
let message: MacroError
8889
let errorSyntax: SyntaxProtocol

Tests/EnumeratorMacroTests/EnumeratorMacroTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ final class EnumeratorMacroTests: XCTestCase {
1515
{{#cases}}
1616
case .{{name}}:
1717
"{{name}}"
18+
19+
20+
1821
{{/cases}}
1922
}
2023
}

Tests/EnumeratorMacroTests/TransformTests.swift

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,17 @@ final class TransformTests: XCTestCase {
4848
}
4949

5050
func testCommentsValueConditionalSection() throws {
51-
do {
52-
let template = """
53-
{{^exists(custom_params(keyValues(comments)))}}
54-
thing!
55-
{{/exists(custom_params(keyValues(comments)))}}
56-
"""
57-
let render = try MustacheTemplate(
58-
string: "{{%CONTENT_TYPE:TEXT}}\n" + template
59-
).render(
60-
testCases[2]
61-
)
62-
XCTAssertEqual(render, "thing!\n")
63-
}
51+
let template = """
52+
{{^exists(custom_params(keyValues(comments)))}}
53+
thing!
54+
{{/exists(custom_params(keyValues(comments)))}}
55+
"""
56+
let render = try MustacheTemplate(
57+
string: "{{%CONTENT_TYPE:TEXT}}\n" + template
58+
).render(
59+
testCases[2]
60+
)
61+
XCTAssertEqual(render, "thing!\n")
6462
}
6563

6664
let testCases: [ECase] = [

0 commit comments

Comments
 (0)