java - 检测到无限循环,部分 ../foo.mustache 先前已加载

标签 java templates mustache handlebars.java

您好,我有两个 Handlebars 模板,如下所示。

foo.mustache

{{#if hasProperties}}
    {{>bar}}
{{/if}}{{^hasProperties}}{{propsName}}{{/hasProperties}}

bar.mustache

{{#propertyObject}}{{>foo}}{{/propertyObject}}

当我编译并运行时,出现以下错误。

infinite loop detected, partial '/templates/foo.mustache' was previously loaded

解决这个问题的正确方法是什么?

最佳答案

我已经找到了这个问题的解决方案。这与模板本身无关。 mustache 文件的顺序正确,但在 Mustache java 实现中有一个属性,其中 default 值设置为 false.

public void setInfiniteLoops(boolean infiniteLoops) link

此方法实际上将设置为接受无限循环,如果您在 mustache 模板本身内运行递归调用,则需要无限循环。

我希望这能帮助任何想要解决类似错误的人。

关于java - 检测到无限循环,部分 ../foo.mustache 先前已加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59100708/

相关文章:

c++ - 为模板类中的无效数据类型生成编译时错误?

javascript - mustache JS : JS not working on mustache's products?

java - 如何加快 Java Web 应用程序的编译速度?

java - Java应用程序中CPU核心数和线程数之间的关系是什么?

c++ - 类型特征 C++ 的错误/错误使用

c++ - 在设置容器的 find() 上崩溃

javascript - 与 "Inverted Selection"相对,有 mustache

javascript - mustache-express - 为 mustache 创建一个 partials 的子目录

java - 在 Spring 中使用属性来制作对象列表

java - 如何重命名 JList 中的 Object[] 列表