feat: Working on node builder
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
// TODO: Remove init(header:...) initializers.
|
||||
public struct Section: NodeRepresentable {
|
||||
@usableFromInline
|
||||
let node: any NodeRepresentable
|
||||
|
||||
@inlinable
|
||||
public init<N: NodeRepresentable>(@NodeBuilder _ build: () -> N) {
|
||||
self.node = build()
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func render() -> String {
|
||||
node.render()
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public init<Content: NodeRepresentable, Separator: NodeRepresentable>(
|
||||
header: String,
|
||||
separator: Separator,
|
||||
@NodeBuilder content: () -> Content
|
||||
) {
|
||||
self.init {
|
||||
Text(header)
|
||||
separator
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public init<Content: NodeRepresentable>(
|
||||
header: String,
|
||||
inline: Bool = false,
|
||||
@NodeBuilder content: () -> Content
|
||||
) {
|
||||
self.init(
|
||||
header: header,
|
||||
separator: inline ? Space().eraseToAnyNode() : NewLine().eraseToAnyNode(),
|
||||
content: content
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user