Skip to content

Commit f8d192b

Browse files
committed
readme, comments, benchmarks
1 parent 43e8b77 commit f8d192b

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

Benchmarks/Benchmarks/ElementaryBenchmarks/Benchmarks.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ struct MyCustomElement<H: HTML>: HTML {
252252
myContent = content()
253253
}
254254

255-
var content: some HTML {
255+
var body: some HTML {
256256
myContent
257257
}
258258
}
259259

260260
struct MyListItem: HTML {
261261
let number: Int
262262

263-
var content: some HTML {
263+
var body: some HTML {
264264
let isEven = number.isMultiple(of: 2)
265265

266266
li(.id("\(number)")) {

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct MainPage: HTMLDocument {
3535
struct FeatureList: HTML {
3636
var features: [String]
3737

38-
var content: some HTML {
38+
var body: some HTML {
3939
ul {
4040
for feature in features {
4141
li { feature }
@@ -122,7 +122,7 @@ struct List: HTML {
122122
var items: [String]
123123
var importantIndex: Int
124124

125-
var content: some HTML {
125+
var body: some HTML {
126126
// conditional rendering
127127
if items.isEmpty {
128128
p { "No items" }
@@ -142,7 +142,7 @@ struct ListItem: HTML {
142142
var text: String
143143
var isImportant: Bool = false
144144

145-
var content: some HTML {
145+
var body: some HTML {
146146
// conditional attributes
147147
li { text }
148148
.attributes(.class("important"), when: isImportant)
@@ -183,7 +183,7 @@ struct Button: HTML {
183183
var text: String
184184

185185
// by exposing the HTMLTag type information...
186-
var content: some HTML<HTMLTag.input> {
186+
var body: some HTML<HTMLTag.input> {
187187
input(.type(.button), .value(text))
188188
}
189189
}
@@ -209,7 +209,7 @@ div {
209209
}
210210

211211
struct MyComponent: HTML {
212-
var content: some HTML {
212+
var body: some HTML {
213213
AsyncContent {
214214
"So does this: \(await getMoreData())"
215215
}
@@ -245,7 +245,7 @@ struct MyComponent: HTML {
245245
// ... their values can be accessed ...
246246
@Environment(MyValues.$userName) var userName
247247

248-
var content: some HTML {
248+
var body: some HTML {
249249
p { "Hello, \(userName)!" }
250250
}
251251
}

Sources/Elementary/Core/CoreModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/// struct FeatureList: HTML {
88
/// var features: [String]
99
///
10-
/// var content: some HTML {
10+
/// var body: some HTML {
1111
/// ul {
1212
/// for feature in features {
1313
/// li { feature }
@@ -58,7 +58,7 @@ extension HTML {
5858
public typealias Content = Body
5959

6060
public var content: Body {
61-
fatalError("content was renamed to body")
61+
fatalError("Please make sure to add a `var body` implementation to your HTML type.")
6262
}
6363
}
6464

Sources/Elementary/Core/Environment.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/// struct MyNumber: HTML {
1212
/// @Environment(Values.$myNumber) var number
1313
///
14-
/// var content: some HTML {
14+
/// var body: some HTML {
1515
/// p { "\(number)" }
1616
/// }
1717
/// }

0 commit comments

Comments
 (0)