Class SelectedValuesHandlebarsHelper

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

    @Component
    public class SelectedValuesHandlebarsHelper
    extends BaseHelper
    The {{selectedValues ...}} handlebars helper is used to output the selected values of a List Content Element.

    The helper allows the developer to configure the separators that are used.

    Separators

    There are two possible separators defined on both selectedNames and selectedValues helpers.
    Attribute Description Default value Example
    separator This is the separator that is output between each selection , (<comma><space>) Ireland, USA, UK
    level-separator This is the separator that is output between each entry within a single selection, where the selection is multi-level > USA>California>San Diego

    Usage

      {{selectedValues element="List Content Element"}}
     

    The above handlebars expression will output the selected list values using the default separators. This is equivalent to the below expression.

       {{publish element="List Content Element"}}
      

    However, the output can be customized using the two separator attribute described above.

       {{#ifSet element="List Content Element}}
       <ul>
        <li>{{{selectedValues element="List Content Element" separator="</li><li>" level-separator=" ⇒ "}}}</li>
       </ul>
       {{/ifSet}}
      

    In the above example, if the List Content Element has any selections made on it, they will be output within an unordered list, as per the example below.

       <ul>
        <li>USA ⇒ California ⇒ San Diego</li>
        <li>Ireland ⇒ Dublin</li>
       </ul>
      
    • Constructor Detail

      • SelectedValuesHandlebarsHelper

        @Autowired
        public SelectedValuesHandlebarsHelper​(IElementAPI elementApi,
                                              IListAPI listApi)
    • Method Detail

      • apply

        public String apply​(Object context,
                            com.github.jknack.handlebars.Options options)
        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.