Class MediaIdHandlebarsHelper

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

    @Component
    public class MediaIdHandlebarsHelper
    extends BaseHelper
    The {{mediaId ...}} handlebars helper gets the Id of a media element within a Content Item.

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

    Attributes

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

    • element - The Media Content Element to get the selected Media Id of.

    Example

      {{{media id=(mediaId element="Media Element") layout="image/640x480"}}}
     

    In the above example, the Id of the Media Element is firstly obtained using this helper (mediaId). This is then passed to the related media handlebars helper, which then outputs the Media using the selected layout.

    • Constructor Detail

      • MediaIdHandlebarsHelper

        @Autowired
        public MediaIdHandlebarsHelper​(IElementAPI elementApi)
    • Method Detail

      • apply

        public Integer 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.