Closed mikebronner closed 6 years ago
Steps to reproduce:
vapor new test-inline-array
cd test-inline-array
vapor xcode -y
Add Leaf to Package.swift:
Package.swift
// swift-tools-version:4.1 import PackageDescription let package = Package( name: "test", dependencies: [ .package(url: "https://github.com/vapor/vapor.git", from: "3.0.4"), .package(url: "https://github.com/vapor/leaf.git", from: "3.0.0-rc.2"), ], targets: [ .target(name: "App", dependencies: ["Leaf", "Vapor"]), .target(name: "Run", dependencies: ["App"]), .testTarget(name: "AppTests", dependencies: ["App"]) ] )
configure.swift
try services.register(LeafProvider()) config.prefer(LeafRenderer.self, for: ViewRenderer.self)
routes.swift
router.get("test", use: TestController().index)
Create the controller in /Sources/App/Controllers/TestController.swift:
/Sources/App/Controllers/TestController.swift
import Vapor final class TestController { func index(_ request: Request) throws -> Future<View> { return try request.view().render("test.leaf") } }
/Resources/Views/test.leaf
Hello! #count(["class", "test"])
http://localhost:8080/test
{"error":true,"reason":"Expected ')' got '[' (\/Users\/mike\/Developer\/test\/Resources\/Views\/test.leaf line: 1 column: 31 range: 40..<40)"}
Updated leaf page to not include ConvertToTemplateData class, I was just testing possible solutions.
Moving this to: https://github.com/vapor/leaf/issues/121. TemplateKit only handles serialization. Leaf is responsible for parsing the files.
Thanks ... wasn't sure.
No worries. Thanks for reporting! :)
Steps to reproduce:
vapor new test-inline-array
cd test-inline-array
vapor xcode -y
Add Leaf to
Package.swift
:configure.swift
(and import Leaf at the top of the file):routes.swift
:Create the controller in
/Sources/App/Controllers/TestController.swift
:/Resources/Views/test.leaf
http://localhost:8080/test
.Updated leaf page to not include ConvertToTemplateData class, I was just testing possible solutions.