【问题标题】:Why doesn't it recognize the Leaf command: #loop为什么它不能识别 Leaf 命令:#loop
【发布时间】:2018-03-30 16:57:26
【问题描述】:

我从一个几乎空白的项目开始,我可以使用这个从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)

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

【问题讨论】:

    标签: swift vapor leaf


    【解决方案1】:

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

    #loop(things, "thing")

    在 Vapor 3 中,这变成了

    #for(thing in things)

    【讨论】:

      猜你喜欢
      • 2013-01-28
      • 1970-01-01
      • 2015-04-21
      • 2019-03-26
      • 2010-11-11
      • 1970-01-01
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      相关资源
      最近更新 更多