Class FirstHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.content.FirstHandlebarsHelper
-
- All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>
@Component public class FirstHandlebarsHelper extends BaseHelper
The {{first}} handlebars helper is used to process the first content item in a section in a different way to the rest of the content items in the section.In general this helper is used as a block level helper, but if used as an inline expression, it returns true for the first content item and false for others.
If there is no currently publishing content item, this helper returns false.
Usage
{{#first}} <ul> {{/first}} <li>{{publish element="Name"}}</li> {{#last}} </ul> {{/last}}
In the above example, an opening ul is output for the first content item in the section and a closing ul is output for the last content item. This allows for all content items to be wrapped with specific code, in this case an unordered list.
-
-
Constructor Summary
Constructors Constructor Description FirstHandlebarsHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
apply(Object context, com.github.jknack.handlebars.Options options)
Theapply
method is the main entry point for handlebars.java helpers.
-
-
-
Method Detail
-
apply
public Object apply(Object context, 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:
context
- The currently executing context.options
- The options.- Returns:
- The generated output.
- Throws:
IOException
- If processing of the expressions fails.
-
-