Skip to content

Commit

Permalink
nio updates, fix #96
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Mar 22, 2018
1 parent 58ef649 commit e0c8bb6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ let package = Package(
],
dependencies: [
// 🌎 Utility package containing tools for byte manipulation, Codable, OS APIs, and debugging.
.package(url: "https://github.com/vapor/core.git", .branch("nio")),
.package(url: "https://github.com/vapor/core.git", from: "3.0.0-rc.2"),

// 📦 Dependency injection / inversion of control framework.
.package(url: "https://github.com/vapor/service.git", .branch("nio")),
.package(url: "https://github.com/vapor/service.git", from: "1.0.0-rc.2"),

// 📄 Easy-to-use foundation for building powerful templating languages in Swift.
.package(url: "https://github.com/vapor/template-kit.git", .branch("nio")),
.package(url: "https://github.com/vapor/template-kit.git", from: "1.0.0-rc.2"),
],
targets: [
.target(name: "Leaf", dependencies: ["Async", "Bits", "CodableKit", "COperatingSystem", "Service", "TemplateKit"]),
Expand Down
10 changes: 6 additions & 4 deletions Sources/Leaf/Service/LeafProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public final class LeafProvider: Provider {
/// See Service.Provider.Register
public func register(_ services: inout Services) throws {
services.register(TemplateRenderer.self) { container -> LeafRenderer in
let config = try container.make(LeafConfig.self, for: LeafRenderer.self)
let config = try container.make(LeafConfig.self)
return LeafRenderer(
config: config,
using: container
)
}

services.register { container -> LeafConfig in
let dir = try container.make(DirectoryConfig.self, for: LeafRenderer.self)
let dir = try container.make(DirectoryConfig.self)
return try LeafConfig(
tags: container.make(for: LeafConfig.self),
tags: container.make(),
viewsDir: dir.workDir + "Resources/Views",
shouldCache: container.environment != .development
)
Expand All @@ -35,5 +35,7 @@ public final class LeafProvider: Provider {
}

/// See Service.Provider.boot
public func boot(_ container: Container) throws { }
public func didBoot(_ container: Container) throws -> Future<Void> {
return .done(on: container)
}
}
21 changes: 21 additions & 0 deletions Tests/LeafTests/LeafTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,26 @@ class LeafTests: XCTestCase {
try XCTAssertEqual(renderer.testRender(home, data), expected)
}

func testGH96() throws {
let template = """
#for(name in names) {
#(name): index=#(index) last=#(isLast) first=#(isFirst)
#if(!isLast) {
}
}
"""
let expected = """
tanner: index=0 last=false first=true
ziz: index=1 last=false first=false
vapor: index=2 last=true first=false
"""
let data = try TemplateDataEncoder().encode([
"names": ["tanner", "ziz", "vapor"]
])
try XCTAssertEqual(renderer.testRender(template, data), expected)
}

static var allTests = [
("testPrint", testPrint),
("testConstant", testConstant),
Expand Down Expand Up @@ -424,6 +444,7 @@ class LeafTests: XCTestCase {
("testKeyEqual", testKeyEqual),
("testInvalidForSyntax", testInvalidForSyntax),
("testTemplating", testTemplating),
("testGH96", testGH96),
]
}

Expand Down
4 changes: 1 addition & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ jobs:

linux:
docker:
- image: norionomura/swift:swift-4.1-branch
- image: codevapor/swift:4.1
steps:
- checkout
- run: apt-get update
- run: apt-get install -yq libssl-dev
- run: swift build
- run: swift test
- run: swift build -c release
Expand Down

0 comments on commit e0c8bb6

Please sign in to comment.