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.
I would assume this may follow the original Merge Tag formatting. Have you tried this?
http://kb.mailchimp.com/merge-tags/all-the-merge-tags-cheatsheet
Use |DATE:FORMAT| to show the current date in a given format. For example, |DATE:d/m/y| where d is replaced by the day, m by the month, and y by the year. View a full reference of date options on the PHP website. This format isn't available for automation workflows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With