Skip to content

Commit

Permalink
Update TagBuilder.swift (#17)
Browse files Browse the repository at this point in the history
If only one Tag supplied in array of arrays, return Tag. If more than one Tag supplied, return GroupTag.
  • Loading branch information
bgisme authored Mar 10, 2022
1 parent 2dcfe16 commit a6d3856
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/SwiftSgml/TagBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ public enum TagBuilder {
}

public static func buildBlock(_ components: [Tag]...) -> Tag {
GroupTag(components.flatMap { $0 })
let flat = components.flatMap { $0 }
if flat.count < 2, let first = flat.first {
return first
}
return GroupTag(flat)
}

public static func buildExpression(_ expression: [Tag]) -> [Tag] {
Expand Down

0 comments on commit a6d3856

Please sign in to comment.