This commit is contained in:
2024-12-03 17:21:14 -05:00
parent f73ded3314
commit 590df275cc
13 changed files with 266 additions and 254 deletions

View File

@@ -0,0 +1,37 @@
public struct Group: TextNode {
@usableFromInline
var content: [any TextNode]
@usableFromInline
var separator: any TextNode
@usableFromInline
init(
content: [any TextNode],
separator: any TextNode = "\n"
) {
self.content = content
self.separator = separator
}
@inlinable
public init(
separator: any TextNode = "\n",
@TextBuilder content: () -> any TextNode
) {
let content = content()
if let many = content as? NodeContainer {
self.content = many.nodes
} else {
self.content = [content]
}
self.separator = separator
}
@inlinable
public var body: some TextNode {
content.reduce("") {
$0 + $1.render() + separator.render()
}
}
}