Class MediaHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.media.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 processed 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 Summary
Constructors Constructor Description MediaHandlebarsHelper(IMediaAPI mediaApi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
apply(Object context, com.github.jknack.handlebars.Options options)
Theapply
method is the main entry point for handlebars.java helpers.
-
-
-
Constructor Detail
-
MediaHandlebarsHelper
@Autowired public MediaHandlebarsHelper(IMediaAPI mediaApi)
-
-
Method Detail
-
apply
public String 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.
-
-