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 Xcode
project and addleaf-provider
as 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
App
target:
.target(name: "App", dependencies: ["Vapor", "FluentProvider", "HealthcheckProvider", "MongoProvider", "LeafProvider"],
- Now, open up the
Config+Setup.swift
file and import theLeafProvider
by specifying it on the top of the file:
import LeafProvider
- Now, we will need to add the
LeafProvider
to our app. We can do this by adding the following line in oursetupProviders...