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

问题描述 投票:0回答:1

嗨,我有两个如下的车把模板。

foo.mustache

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

bar.mustache

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

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

检测到无限循环,部分'/templates/foo.mustache'为先前加载

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

java templates mustache handlebars.java
1个回答
2
投票

我已经找到了解决此问题的方法。这与模板本身无关。 mustache文件的顺序正确,但是髭Java实现中有一个property,其中default的值设置为false

public void setInfiniteLoops(boolean infiniteLoops) link

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

我希望这对希望解决类似错误的人有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.