Mandrill Templates With Handlebars - How To Format Date - handlebars.js

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:
You should use {{date}} instead of {{#date}}
You should use double quotes for formatting
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.

Related

2sxc: Field Date and Time default value

I need to have in my fields a datetime content type.
Looking for documentation I found same here http://2sxc.org/en/Docs-Manuals/Feature/feature/2874
Date and Time
no relevant settings to explain. Note that the
output-template will usually choose to show only the date, only the
time etc.
So it's the same data-field no matter what you're actually
entering.
How can I set a default date value like a Datetime.Now for the editing input data field?
I tryed with varius commands but it gives me invalid date.
I alsa tryed the dnn token [DateTime: Now] but it doesn't work.
Thanks
To prefil the date-time there are two options
the link in the dnn-page which creates a new-item could pass this in as a prefill - http://2sxc.org/en/Docs-Manuals/Prefill-new-Forms
there is a hidden API which could do it using JavaScript, but it's not official yet, fairly technical and still prone to change. So I would use #1

extract elasticsearch date from a <start-date>/<duration> XBRL-JSON format

I am storing XBRL JSON using elasticsearch.
This xBRL-JSON OIM spec describes the oim:period property:
Otherwise, an ISO 8601 time interval representing the {interval}
property, expressed in one of the following forms:
<start>/<end>
<start>/<duration>
<duration>/<end>
Where <start> and <end> are valid according to the xsd:dateTime datatype, and <duration> is valid according to xsd:duration.
Examples from arelle's plugin look like this:
2016-01-01T00:00:00/PT0S
2015-01-01T00:00:00/P1Y
I notice that arelle's plugin exclusively produces this format:
<start>/<duration>
My question
Is there a way to save at least the <start> part as a date type in elasticsearch?
Ideas I had:
elastichsearch only (my preference)
Use a custom date format which anticipates the /<duration> part, but ignores it
I haven't checked Joda yet; will it ignore characters in the date format if they aren't part of the special character? Like the "/" delimiter or the "P" which precedes any duration value (like PT0S and P1Y above)?
EDIT So the single-quote character escapes literals; this works yyyy'/P' will accept a value '2015/P'. However, the rest of the duration could be more dynamic
Re: dynamic; will Joda accept regex or wildcard character like "\d" or "+" qualifier so I can ignore all the possible variations following the P?
Use a character filter to strip out the /<duration> part before saving only <start>as datetime. But I don't know if character filters happen before saving as type: date. If they don't, the '/`part isn't stripped, and I wouldn't be passing valid date strings.
Don't use date type: Use a pattern tokenizer to split on /, and at least the two parts will be saved as separate tokens. Can't use date math, though.
Use a transformation; although it seems like this is deprecated. I read about using copy_to instead, but that seems to combine terms, and I want to break this term apart
Some sort of plugin? Maybe a plugin which will fully support this "interval" datatype described by the OIM spec... maybe a plugin which will store its separate parts...?
change my application (I prefer to use elasticsearch-only techniques if possible)
I could edit this plugin or produce my own plugin which uses exclusively <start> and <end> parts, and saves both into separate fields;
But this breaks the OIM spec, which says they should be combined in a single field
Moreover it can be awkward to express an "instant" fact (with no duration; the PT0S examples above); I guess I just use the same value for end property as start property... Not more awkward than a 0-length duration (PT0S) I guess.
Not a direct answer, but it's worth noting that the latest internal drafts of the xBRL-JSON specification have moved away from the the single-field representation. Although the "/" separated notation is an ISO standard, tool support for it appears to be extremely poor, and so the working group has chosen to switch to separate fields for start and end dates. I would expect Arelle support to follow suit in due course.

API Blueprint parameter name not displaying

I am new to API Blueprint so please excuse my naivety here. I am trying to format some parameters such as given in the Aglio example:
+ Parameters
+ name (optional, string, `alice`) ... Search for a user by name
+ joinedBefore (optional, string, `2011-01-01`) ... Search by join date
+ joinedAfter (optional, string, `2011-01-01`) ... Search by join date
However, all that is displaying for the name of the parameter is the index of the parameter. Here is the display from the Atom API-Display package: https://atom.io/packages/api-blueprint-preview.
How can I make it display the name of the parameter?
The snippet of blueprint looks OK. Just for the sake - can you share the URI template used to defined the respective resource? The URI template should contain something like this:
{?name,joinedBefore,joinedAfter}
e.g.
# Resource [/resource{?name,joinedBefore,joinedAfter}]
But again the blueprint looks OK so it might be a problem with Aglio or the preview package itself. Best to check and report at https://github.com/danielgtaylor/aglio/issues?state=open or https://github.com/danielgtaylor/atom-api-blueprint-preview/issues.

How can I make input fields accept locale dependent number formatting?

I'm working on a Spring MVC Project and ran into a problem with the internationalization in forms, especially the number formatting.
I already use fmt:formatNumber to format the numbers according to the current selected locale.
<fmt:formatNumber value="${object[field]}"/>
Like this, number formatting works well when I display numbers. But how about the forms?
At the moment, the input fields that are supposed to receive float values are prefilled with 0.0 and expect me to use "." as decimal separator, no matter what locale is selected. Values containing "," are refused by the server (...can not convert String to required type float...).
How can I make my input fields use and accept the appropriate number format as well?
Did you have a look at #NumberFormat? If you annotate the property the input field is bound to, this should result in the proper formatting. Something like:
#NumberFormat(style = Style.NUMBER)
private BigDecimal something;
This style is the "general-purpose number format for the current locale". I guess, the current locale is determined threadwise from the LocaleContextHolder.
Your app needs to be annotation-driven, also see the section "Annotation-driven Formatting" in the docs.
You might want to take a look at the DecimalFormatSymbols as suggested in this answer.

How can a custom Drupal date format be added?

How do you add a custom Drupal date format. I want to display the date without hours and minutes, but the options don't include it.
Do the following:
Administration » Configuration » Regional and language » Date and Time
There you will see a tab for format.
Create a new format string "Y-M-d".
Make this as your default for all date fields and you won't see the seconds any more.
You don't need the date module for basic formatting.
Cheers,
Vishal
Below is the image so that you know where it is.
You will see a button Add format in this path admin/config/regional/date-time/formats
Then, type your format there. This will help you: http://php.net/manual/en/function.date.php
After adding your format, you can choose in the tab Types
Oops. I had this tab open in my browser for long time and didn't see the other answer.

Resources