Skip to content

Tags config, files protocol, and context passing

Pre-release
Pre-release
Compare
Choose a tag to compare
@tanner0101 tanner0101 released this 06 Mar 00:58
c3941cf
This patch was authored and released by @tanner0101.

Adds new Leaf configuration options, including custom tags, to application.

app.leaf.tags["foo"] = FooTag()
app.leaf.files = TestFiles()
app.leaf.configuration.rootDirectory = "/"

Adds support for passing Request and Application to LeafKit's userInfo storage.

struct FooTag: LeafTag {
    func render(_ context: LeafContext) throws -> LeafData {
        context.request // Request?
        context.application // Application?
        ...
    }
}

These will be set automatically when using app.view or req.view.