I want to create a handlebar java template something like:
"This is a sample template with {{parameter1}} {{#if object_list}} {{#each object_list}} {{object_list.somevar}} {{object_list.othervar}} {{/each}}{{/if}}"
Before I could do object_list.something, I am not even able to do a simple loop. I tried the following:
Map<String, String> map = new HashMap<String, String>();
map.put("people", "[ Yehuda Katz, Alan Johnson, Charles Jolley ]");
map.put("k2", "v2");
System.out.println("Map: "
+ handlebars.compileInline("{{#each people}} {{@index}}:{{this}} \n {{/each}}")
.apply(map));
}
and it gives:
Map: :[B@6cd8737
:false
Any pointers on how to achieve this? Note: These parameters will be received in a json file, so I cannot(or will prefer not to) create list of objects actually.
I am following: https://github.com/jknack/handlebars.java
Could do it with base mustache. Works as expected. Following is an example: