【问题标题】:quarkus qute: iteration metadata count, hasNext, ... not workingquarkus qute:迭代元数据计数,hasNext,...不工作
【发布时间】:2022-01-08 11:55:34
【问题描述】:

制作教程时

https://kubebyexample.com/en/learning-paths/developing-quarkus-kubernetes/templating-qute-templating-engine/rendering-periodic

出现如下错误

quarkus.qute.TemplateException: Entry "count" not found in the data map in expression {count} in template reports/v1/report_01.json.template on line 5

配置:Quarkus 2.6.1.Final、surefire-plugin 3.0.0-M5、compiler-plugin 3.8.1

当从 json 模板中删除“计数”时,它可以完美运行

我还尝试了另一个示例(来自 Sebastian Daschner)

https://github.com/sdaschner/quarkus-playground/tree/qute-example/src/main/java/com/sebastian_daschner/entries

这与 1.3.1.Final 完美搭配,但更新到 2.6.1.Final 后会出现同样的错误。

你能帮帮我吗? 托马斯

【问题讨论】:

    标签: java quarkus quarkus-qute


    【解决方案1】:

    我有同样的问题。来自文档:

    但是,这些键不能直接使用。 相反,使用前缀来避免可能与变量发生冲突 从外部范围。默认情况下,迭代元素的别名 带有下划线的后缀用作前缀。例如, hasNext 键必须在 {#each} 部分内以 it_ 为前缀: {it_hasNext}。

    升级后我必须将我的应用程序的{count} 更新为{it_count}{item_count}

    {#each items}
      {it_count}. {it.name} 
      {#if it_hasNext}<br>{/if} 
    {/each}
    

    类似的 for 循环:

    {#for item in items}
      {item_count}. {item.name} 
      {#if item_hasNext}<br>{/if} 
    {/each}
    

    Quarkus reference

    【讨论】:

    • 非常感谢您的帮助。我没有注意到文档中的这一段。抱歉 - 下次会更彻底。
    猜你喜欢
    • 2021-02-15
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 2010-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多