Skip to content

Commit 11ab61c

Browse files
authored
Merge pull request #144 from vapor/tn-beta-1
beta 1
2 parents 546b770 + 120ceac commit 11ab61c

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

Package.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import PackageDescription
33

44
let package = Package(
55
name: "leaf",
6+
platforms: [
7+
.macOS(.v10_14)
8+
],
69
products: [
710
.library(name: "Leaf", targets: ["Leaf"]),
811
],

Sources/Leaf/LeafProvider.swift

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ import Vapor
33
public final class LeafProvider: Provider {
44
public init() { }
55

6-
public func register(_ s: inout Services) {
7-
s.register(LeafRenderer.self) { c in
8-
return try LeafRenderer(
9-
config: c.make(),
10-
threadPool: c.application.threadPool,
11-
eventLoop: c.eventLoop
6+
public func register(_ app: Application) {
7+
app.register(LeafRenderer.self) { app in
8+
LeafRenderer(
9+
config: app.make(),
10+
threadPool: app.make(),
11+
eventLoop: app.make()
1212
)
1313
}
1414

15-
s.register(ViewRenderer.self) { c in
16-
return try c.make(LeafRenderer.self)
15+
app.register(ViewRenderer.self) { app in
16+
app.make(LeafRenderer.self)
1717
}
1818

19-
s.register(LeafConfig.self) { c in
20-
let directory = try c.make(DirectoryConfiguration.self)
19+
app.register(LeafConfig.self) { app in
20+
let directory = app.make(DirectoryConfiguration.self)
2121
return LeafConfig(rootDirectory: directory.viewsDirectory)
2222
}
2323
}
@@ -38,3 +38,13 @@ extension LeafRenderer: ViewRenderer {
3838
}
3939
}
4040
}
41+
42+
extension Request {
43+
public var leaf: LeafRenderer {
44+
LeafRenderer(
45+
config: self.application.make(),
46+
threadPool: self.application.make(),
47+
eventLoop: self.eventLoop
48+
)
49+
}
50+
}

0 commit comments

Comments
 (0)