Class PublishHandlebarsHelper

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

    @Component
    public class PublishHandlebarsHelper
    extends BaseHelper
    The {{publish ...}} handlebars helper is used to "publish" a Content Element.

    It should be noted that in many cases this helper outputs HTML code, so it should be surrounded with a triple-stash instead of the standard double-stash}}, when required.

    Content Elements that would be expected to contain T4 Tags in their output have those tags processed directly by this helper. These element types are HTML, Media and Section/Content Links.

    Usage

    Attributes

    The expression itself is quite simple, taking only a single attribute.

    • element - The Content Element to be published

    Standard expression

      {{publish element="Content Element"}}
     

    The above handlebars expression is a standard expression that calls the publish helper. In this use scenario, the returned string is escaped.

    Triple-stashed expression

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

    The above handlebars expression is a triple-stashed expression. Any HTML code returned by standard double-stashed is escaped. If you expect a helper to return HTML code, which you want embedded in the published page, this triple-stashed variant should be used.

    • Constructor Detail

      • PublishHandlebarsHelper

        @Autowired
        public PublishHandlebarsHelper​(IElementAPI elementApi)
    • 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.