Class DateElementHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.content.element.DateElementHandlebarsHelper
-
- All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>
@Component public class DateElementHandlebarsHelper extends BaseHelper
The {{dateElement ...}} handlebars helper is a simple helper to get the value of a Date Element within a Content Item.If there is no currently publishing content item, this helper returns a zero'd date, one with all fields set to zero. The related
dateFormat
helper interprets this as a blank date and outputs an empty string when they are used together.Attributes
The expression itself is quite simple, taking only a single attribute.
- element - The Date Content Element to get the date value from.
Example
{{{dateFormat (dateElement element="Date Element") "long" time="medium"}}}
In the above example, the value for the Date Element is firstly obtained using this helper (dateElement). This is then passed to the related
dateFormat
handlebars helper, which then outputs the Date using the provided configuration.
-
-
Constructor Summary
Constructors Constructor Description DateElementHandlebarsHelper(IElementAPI elementApi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PDDateTime
apply(Object context, com.github.jknack.handlebars.Options options)
Theapply
method is the main entry point for handlebars.java helpers.
-
-
-
Constructor Detail
-
DateElementHandlebarsHelper
@Autowired public DateElementHandlebarsHelper(IElementAPI elementApi)
-
-
Method Detail
-
apply
public PDDateTime apply(Object context, com.github.jknack.handlebars.Options options)
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:
context
- The currently executing context.options
- The options.- Returns:
- The generated output.
-
-