edit

Leaf Provider

After you've added the Leaf Provider package to your project, setting the provider up in code is easy.

Add to Droplet

First, register the LeafProvider.Provider with your Droplet.

import Vapor
import LeafProvider

let config = try Config()
try config.addProvider(LeafProvider.Provider.self)

let drop = try Droplet(config)

...

Configure Droplet

Once the provider is added to your Droplet, you can configure your Droplet to use the Leaf view renderer.

Config/droplet.json

{
    ...,
    "view": "leaf",
    ...
}

Seealso

Learn more about configuration files in the Settings guide.

Manual

You can also set the drop.view property manually if you want to hardcode your view renderer.

import Vapor
import LeafProvider

let drop = try Droplet()

drop.view = LeafRenderer(viewsDir: drop.viewsDir)

Done

Next time you boot your application, your views will be rendered using Leaf.