Thanks @mikhailvolkov. I am currently exploring the third option, defining a custom Handlebar Helper. I can get a toy helper to work.
With the following in my Javascript:
handlebars.registerHelper("hostname", () =>
[...new Set([host1, host1, host2])]);
and this in my content:
<div>{{hostname}}</div>
I get host1, host2 in my plugin, as desired. However, I can’t figure out the syntax to apply this same logic to the real case. With:
{{#each data}} {{"hostname.keyword"}} {{/each}}
I get all the hosts (including duplicates) in my plugin. So I am trying to pass this as the argument to my javascript function and was thinking that something like this should work. In my javascript:
handlebars.registerHelper("hostname", (allhosts) =>
[...new Set(allhosts)]);
And this in my content:
<div>{{#hostname data}} {{"hostname.keyword"}} {{/hostname}}</div>
However, in my plugin this prints:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
I have also tried this in my content without success:
<div>{{hostname ({{#each data}} {{"hostname.keyword"}} {{/each}})}}</div>
Any other ideas?