Class MediaHandlebarsHelper

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

    @Component
    public class MediaHandlebarsHelper
    extends BaseHelper
    The {{{media ...}}} handlebars helper should be used to process Media.

    Usage

    The {{{media ...}}} handlebars helper is a simple helper that allows Media to be procesed within the page. As most Media Layouts return HTML code, the handlebars expression should be triple-stashed. If this is not done, any returned HTML will be escaped.

    Attributes

    The media helper has one required (id) and one optional (layout) attribute.

    • id - The id attribute is required and must be set to the id of the Media to be processed.
    • layout - The layout attribute is optional. If set, the Media will be processed using the provided layout. If it is not set, the default layout for the media type will be used instead.

    Example

      {{{media id="123" layout="image/640x480"}}}
     

    In the above example, the Media with id 123 should be processed using the image/640x480 Media Layout. Note that the handlebars expression is triple-stashed. This is done to ensure that returned HTML is not escaped.

    • Constructor Detail

      • MediaHandlebarsHelper

        public MediaHandlebarsHelper()
    • 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.