Reputation: 643
Issue with rendering of nested lists:
I have a class:
public MyRecord
{
String id;
List<String > tags;
}
I have an object named 'records' which is of a type: List of 'MyRecord'.
I am trying to render itin JSON, using a template.
This is what I would like to do:
#{list records, as:'record'}
{"c":[
{"v":"${record.id}"},
#{list ${record.list}, as:'tag'}
{"v":"${tag}"}
#{/list}
]}
#{/list}
Unfortunately ${record.list} is not supported, and I failed to find a working solution.
Of course, I can add a method to MyRecord which will "render" the "tags" into the needed format, and use this method instead of the inner #{list}, but that's isn't in line with the templates approach. I am open to ideas to modify the data structure, if this will help to achieve the goal.
Thanks Max
Upvotes: 0
Views: 641
Reputation: 4896
${record.list} should be record.tags
#{list items:records, as:'record'}
{"c":[{"v":"${record.id}"},
#{list items:record.tags, as:'tag'}
{"v":"${tag}"}
#{/list}
]}
#{/list}
Upvotes: 2