Mandrill has a great feature that allows one to use Handlebars in templates to customize email content. See docs here.
One of the helpers that Madnrill supports is date
that can be used like {{#date}}
. The default date format is d/m/Y
. My question is how can I specify a different date format (e.g. yyyy
)?
I need to display something like 2015 Name
. I tried:
{{#date yyyy}} Name
- displays 05/31/15
(default format and seems to erase any HTML after it).{{#date 'yyyy'}} Name
- displays {{#date 'yyyy'}} Name
(can't be parsed).{{#date yyyy}}{{/date}} Name
- displays 05/31/15 Name
(default format).{{#date 'yyyy'}}{{/date}} Name
- displays {{#date 'yyyy'}}{{/date}} Name
(can't be parsed).Appreciate you help ;)
The issue was 2-fold:
{{date}}
instead of {{#date}}
The correct syntax would be {{date "Y"}}
.
Mandrill also updated their docs that now provide more details on handlebars syntax.