ra1028/Carbon

[Idea] Declarative syntax like SwiftUI with function builder

ra1028 opened this issue · 0 comments

Checklist

Description

Add support declarative syntax like SwiftUI with function builder for Swift5.1.
It replaces closire style syntax added in Carbon 1.0.0.-rc.1.

renderer.render {
    Label("foo")
    Label("bar")
    Label("baz")

    if flag {
        Label("qux")
    }
}
renderer.render {
    Section(id: "section1") {
        Label("foo")
        Label("bar")
        Label("baz")
    }

    Section(
        id: "section2",
        header: Label("header"),
        footer: Label("footer"),
        cells: {
            Label("qux")
            
            if flag {
                Label("quux")
            }
        }
    )
}

Motivation and Context

Wants to simplify the creation rendering like as List in SwiftUI.

Proposed Solution

Add support @functionbuilder for Renderer.render and Section initializer.

Discussion

Agree 👍 or Disagree 👎