mirror of https://github.com/vapor/docs.git
Updated for Leaf 4.0.0 (#565)
Updated for Leaf 4.0.0 Co-authored-by: rpstro02 <email>
This commit is contained in:
parent
a73af2c380
commit
96d1663c50
|
|
@ -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"])
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue