1

Hi I have two handlebars templates which is as below.

foo.mustache

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

bar.mustache

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

When I compile this and run, I get the following error.

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

What is the proper way to fix this?

Imesh Chandrasiri
  • 5,558
  • 15
  • 60
  • 103

1 Answers1

3

I've found the solution for this issue. It's not something related to the template itself. The mustache files were in correct order but there is a property in the mustache java implementation where default value is set to false.

public void setInfiniteLoops(boolean infiniteLoops) link

this method will actually set to accept infinite loops which will be needed if you are running a recursive call inside the mustache template itself.

I hope this will help anyone looking to solve a similar kind of error.

Imesh Chandrasiri
  • 5,558
  • 15
  • 60
  • 103