If I pass a numeric value to a SendGrid dynamic template, is there any way of formatting the value?
ie, if I pass the following object to the templating engine:
{
"value": 8.7
}
is there a way to format it, say, to 2 dp?
{{format value $0.00}}
would return $8.70
I'm just trying to avoid having to create new properties for every numeric/price on all of my models purely for displaying a monetary value.
Example of what the formatting would be is similar to C#: https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings
Thanks
Twilio SendGrid developer evangelist here.
I'm afraid there is not a function for formatting currencies in a SendGrid template. You can see the full SendGrid templates Handlebars reference here and while there is a date formatter, that is the only formatter available.
I probably wouldn't create new properties for every numeric/currency, just format the properties that are currencies before you pass them to the template to send the email.