Class DateFormatHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.utility.DateFormatHandlebarsHelper
-
- All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>
@Component public class DateFormatHandlebarsHelper extends BaseHelper
The {{dateFormat ...}} handlebars helper extends the core dateFormat that is provided as part of handlebars.java.The main difference between the two is that the extended version correctly interprets "blank" dates, for instance blank Publish or Expiry dates.
When a blank date is encountered this extended helper returns a blank string.
Usage
The {{dateFormat ...}} helper takes the following format.
{{dateFormat date ["format"] [format="format"][locale="locale"][tz=timeZone|timeZoneId] [time="format"]}}
Attributes
Format parameters is one of:- "full": full date format. For example: Tuesday, June 19, 2012
- "long": long date format. For example: June 19, 2012
- "medium": medium date format. For example: Jun 19, 2012
- "short": short date format. For example: 6/19/12
- "pattern": a
DateTimeFormatter
pattern.
Otherwise, the default formatter will be used. The format option can be specified as a parameter or hash (a.k.a named parameter).
- The "locale" parameter can be use to select a locale, e.g. "de" or "en_GB". It defaults to the system locale.
- The "tz" parameter is the time zone to use, e.g. "Europe/Berlin" or "GMT-8:00". It defaults to the system time zone.
- The "time" parameter specifies the format of the time part, it can be "full", "long", "medium" or "short". If you do not specify it only the date part will appear in the output string.
-
-
Constructor Summary
Constructors Constructor Description DateFormatHandlebarsHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
apply(Object value, com.github.jknack.handlebars.Options options)
Theapply
method is the main entry point for handlebars.java helpers.
-
-
-
Method Detail
-
apply
public Object apply(Object value, com.github.jknack.handlebars.Options options) throws IOException
Description copied from class:BaseHelper
Theapply
method is the main entry point for handlebars.java helpers.It is called internally by the handlebars.java engine when a matching handlebars.java expression is encountered.
- Specified by:
apply
in interfacecom.github.jknack.handlebars.Helper<Object>
- Specified by:
apply
in classBaseHelper
- Parameters:
value
- The currently executing context.options
- The options.- Returns:
- The generated output.
- Throws:
IOException
- If processing of the expressions fails.
-
-