-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Description
One feature of mustache that we are not currently taking advantage of is "functions", also sometimes referred to as lambdas.
It's not clear how much value we can add with these, but seems like worthy of investigation.
One of the use cases I have in mind is date formatting. We now provide a {{date}} variable in the mustache variables applied to action parameters, in ISO format. How might you provide a function which can format that date with a traditional date formatter? The challenge is, the arguments have to be in the "body" of the function invocation.
Here's an example of how this might work:
{#date-format}}{{date}} MM/DD/YY{{/date-format}}
The date-format function would be provided by us, and it's "arguments" would be <iso-date> MM/DD/YY. So the function would parse the arguments expecting a date as the first part, and the format as the second.
So many issues tho.
Presumably dates coming out of ES that are not under our control could be in any date format, so it's not clear how we'd parse; maybe we need a better separator like <iso-date> --- MM/DD/YY.
Ideally we could support various sorts of "string functions", and so dealing with some kind of separator story that allows strings to be transformed and additional arguments seems really hard/yucky. I think maybe we'd need to go with something #<iso-date>#MM-DD-YY# where the arg delimiter is passed as the first char, kinda thing.
We'd likely need a specialized "test" environment for this - the current action tester (beside the action editor) doesn't do any mustache templating, and shouldn't, because it doesn't have access to alert data.