Class LastHandlebarsHelper

  • All Implemented Interfaces:
    com.github.jknack.handlebars.Helper<Object>

    @Component
    public class LastHandlebarsHelper
    extends BaseHelper
    The {{last}} handlebars helper is used to process the last 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 last content item and false for others.

    If there is no currently publishing content item, this helper returns false.

    Usage

      <h2>{{publish element="Name"}}</h2>
      {{#not (last)}}
       <hr />
      {{/not}}
     

    In the above example, for all content items except the last one in the section, a horizontal rule is output after each content item, but not after the last one.

    See Also:
    FirstHandlebarsHelper, FirstOfTypeHandlebarsHelper, LastOfTypeHandlebarsHelper
    • Constructor Detail

    • Method Detail

      • apply

        public Object apply​(Object context,
                            com.github.jknack.handlebars.Options options)
                     throws IOException
        Description copied from class: BaseHelper
        The apply 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 interface com.github.jknack.handlebars.Helper<Object>
        Specified by:
        apply in class BaseHelper
        Parameters:
        context - The currently executing context.
        options - The options.
        Returns:
        The generated output.
        Throws:
        IOException - If processing of the expressions fails.