Search code examples
javamustache

{{parent.child.0.field}} it not resolved, if child is java.util.Set. Works if it was a java.util.List


Template:

{{parent.child.0.field}}

Context:

Mustache.Compiler c = Mustache.compiler();
Parent parentObj = new Parent();
Map<String, Object> ctx = Maps.newHashMap();
ctx.put("parent", parentObj);
c.compile(templateHtml).execute(ctx);

Exception:

"exception" : "com.samskivert.mustache.MustacheException$Context",
  "message" : "Missing context for compound variable 'parent.child.0.field' on line 1. '0' was not found."

Any workaround without changing the template or datatype of Child from Set to List ?


Solution

  • It's because Set dosn't have get(int index) method like List.