Quick question on mustache:
Is it possible to evaluate a conditional on a list just once? That is, instead of iterating and applying the template to each element in the array, evaluate it as non-empty and do stuff in it only once. For example
{{#array}}
{"terms": { "foo": "{{#toJson}}bar{{/toJson}}" }}
{{/array}}
would be rendered as
{"terms": {"foo": ["bar1", "bar2", "bar3"]}}
if array is a non-empty list, and if empty the block is not evaluated. Tags with # and / are placeholders. Hope this makes sense.
Note: If this is syntactically not possible with mustache, we can obviously just surround all of the sub-queries with something like a bool-should block. This however necessitates some akward stuff with commas or a final match_all, match_none query.