Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #5 from SwiftDocOrg/string-builder-additions
Browse files Browse the repository at this point in the history
Implement buildIf and buildEither for StringBuilder
  • Loading branch information
mattt committed Apr 10, 2020
2 parents 8d38d83 + 34cfac4 commit 1083e47
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Sources/CommonMarkBuilder/StringBuilder.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
@_functionBuilder
public struct StringBuilder {
// MARK: buildBlock

public static func buildBlock(_ string: String) -> String {
return string
}

public static func buildBlock(_ strings: String...) -> String {
return strings.joined(separator: "\n\n")
}

// MARK: buildIf

public static func buildIf(_ string: String?) -> String {
return string ?? ""
}

// MARK: buildEither

public static func buildEither(first: String) -> String {
return first
}

public static func buildEither(second: String) -> String {
return second
}
}

0 comments on commit 1083e47

Please sign in to comment.