Updated for Leaf 4.0.0 (#565)

Updated for Leaf 4.0.0

Co-authored-by: rpstro02 <email>
This commit is contained in:
rpstro02 2020-11-13 02:26:21 -05:00 committed by GitHub
parent a73af2c380
commit 96d1663c50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -71,8 +71,8 @@ Hello, #(name)!
Then, register a route (usually done in `routes.swift` or a controller) to render the view.
```swift
router.get("hello") { req -> Future<View> in
return try req.view.render("hello", ["name": "Leaf"])
router.get("hello") { req -> EventLoopFuture<View> in
return req.view.render("hello", ["name": "Leaf"])
}
```

View File

@ -53,7 +53,7 @@ struct WelcomeContext: Encodable {
var title: String
var numbers: [Int]
}
return try req.view.render("home", WelcomeContext(title: "Hello!", numbers: [42, 9001]))
return req.view.render("home", WelcomeContext(title: "Hello!", numbers: [42, 9001]))
```
That will expose `title` and `numbers` to our Leaf template, which can then be used inside tags. For example:
@ -124,7 +124,7 @@ struct SolarSystem: Codable {
let planets = ["Venus", "Earth", "Mars"]
}
return try req.view.render("solarSystem", SolarSystem())
return req.view.render("solarSystem", SolarSystem())
```
We could then loop over them in Leaf like this: