Adding Leaf Provider
To add Leaf-rendering support to our Vapor application, we will need to use Leaf Provider. It uses the same Leaf package under the hood, but implements Vapor's Provider protocol so that it can be used without writing much code and specifying it as our view renderer in the droplet.json config. To add Leaf Provider to our Vapor app, we will need to perform the following steps:
- Open up our
ShoppingListServer Xcodeproject and addleaf-provideras a dependency inside ourPackage.swift:
.package(url: "https://github.com/vapor/leaf-provider.git", .upToNextMajor(from: "1.1.0")),
- Next, specify it as a dependency for our
Apptarget:
.target(name: "App", dependencies: ["Vapor", "FluentProvider", "HealthcheckProvider", "MongoProvider", "LeafProvider"],
- Now, open up the
Config+Setup.swiftfile and import theLeafProviderby specifying it on the top of the file:
import LeafProvider
- Now, we will need to add the
LeafProviderto our app. We can do this by adding the following line in oursetupProviders...