Class MediaIdHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.content.element.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 Summary
Constructors Constructor Description MediaIdHandlebarsHelper(IElementAPI elementApi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Integer
apply(Object context, com.github.jknack.handlebars.Options options)
Theapply
method is the main entry point for handlebars.java helpers.
-
-
-
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
Theapply
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 interfacecom.github.jknack.handlebars.Helper<Object>
- Specified by:
apply
in classBaseHelper
- Parameters:
context
- The currently executing context.options
- The options.- Returns:
- The generated output.
-
-