feat: Working on node builder
This commit is contained in:
26
Sources/CliDoc/Node.swift
Normal file
26
Sources/CliDoc/Node.swift
Normal file
@@ -0,0 +1,26 @@
|
||||
// swiftlint:disable type_name
|
||||
public protocol Node: NodeRepresentable {
|
||||
associatedtype _Body: NodeRepresentable
|
||||
typealias Body = _Body
|
||||
|
||||
@NodeBuilder
|
||||
var body: Body { get }
|
||||
}
|
||||
|
||||
// swiftlint:enable type_name
|
||||
|
||||
public extension Node {
|
||||
@inlinable
|
||||
func render() -> String {
|
||||
body.render()
|
||||
}
|
||||
}
|
||||
|
||||
public struct Foo: Node {
|
||||
|
||||
public init() {}
|
||||
|
||||
public var body: some NodeRepresentable {
|
||||
LabeledContent("Foo") { "Bar" }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user