I am starting out with an almost blank project and I can render a simple page from welcome.leaf using this:
router.get("view") { req -> Future<View> in
let leaf = try req.make(LeafRenderer.self)
return leaf.render("welcome")
}
However, if I put #loop into welcome.leaf I get this message:
[ ERROR ] TemplateError.serialize: No tag named `loop` is registered. in /Users/david/CloudStation/XcodeProjects/Vapor3affordat/Resources/Views/welcome.leaf line: 24 column: 1 range: 580..<785 (TemplateSerializer.swift:59)
Why does it not recognize the loop leaf command?
In Leaf 3 #loop()
has been renamed to #for
. The syntax has also changed. Vapor 2:
#loop(things, "thing")
In Vapor 3 this becomes
#for(thing in things)