Class PreviewHandlebarsHelper

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

    @Component
    public class PreviewHandlebarsHelper
    extends BaseHelper
    The {{#preview}} handlebars helper is a simple helper to allow processing of blocks to in preview only.

    Usage

    The preview handlebars helper is a block level helper. It allows blocks to be processed based on whether the current context is preview or not.

    Example

      {{#preview}}
       <div class="t4-info">
         <span class="t4-channel">This is a preview of {{channelName}}</span>
         <span class="t4-publish-url">Publish URL<br />{{publishURL}}</span>
       </div>
      {{else}}
       <!-- Output something to the published page -->
      {{/preview}}
     

    In the above example, in preview only, a div is output with the name of the Channel and the URL of the published page.

    • Constructor Detail

      • PreviewHandlebarsHelper

        @Autowired
        public PreviewHandlebarsHelper​(IPageAPI pageApi,
                                       IHandlebarsAPI handlebarsApi)
    • 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.