为什么它不能识别 Leaf 命令:#loop

Why doesn't it recognize the Leaf command: #loop

我从一个几乎空白的项目开始,我可以使用以下方法从 welcome.leaf 渲染一个简单的页面:

router.get("view") { req -> Future<View> in
    let leaf = try req.make(LeafRenderer.self)
    return leaf.render("welcome")
}

但是,如果我将 #loop 放入 welcome.leaf,我会收到此消息:

[ 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)

为什么它不识别循环叶命令?

在 Leaf 3 中,#loop() 已重命名为 #for。语法也发生了变化。蒸汽 2:

#loop(things, "thing")

在 Vapor 3 中,这变成了

#for(thing in things)