1

制作教程时

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 后会发生同样的错误。

你能帮帮我吗?托马斯

4

1 回答 1

0

我遇到过同样的问题。从文档中:

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

升级后我必须更新{count}to{it_count}{item_count}for 我的应用程序。

{#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}

夸库斯参考

于 2022-01-24T18:26:20.400 回答