您好,我有两个 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/